Skip to content

Instantly share code, notes, and snippets.

@Jack-Saleem
Created July 17, 2016 13:58
Show Gist options
  • Save Jack-Saleem/59c7d7ccb5148edf0499f01d85decd56 to your computer and use it in GitHub Desktop.
Save Jack-Saleem/59c7d7ccb5148edf0499f01d85decd56 to your computer and use it in GitHub Desktop.
codeforces 437A TheChildandHomework program in java
import java.util.Scanner;
public class TheChildandHomework
{
public static void main(String[] args)
{
Scanner z=new Scanner(System.in);
int[] a=new int[4];
for(int i=0;i<a.length;i++)
a[i]=z.nextLine().length()-2;
int k1=0;
String x="";
for(int i=0;i<a.length;i++){
int k=0;
int p=0;
for(int j=0;j<a.length;j++){
if(j!=i){
if(a[i]>=2*a[j])
k++;
}
}
for(int j=0;j<a.length;j++){
if(j!=i){
if(a[i]<=a[j]/2)
p++;
}
}
if(k==3 || p==3){
x+=Integer.toString(i);
}
}
if(x.length()==1){
if(Integer.parseInt(x)==0){
System.out.println("A");
} else if(Integer.parseInt(x)==1){
System.out.println("B");
} else if(Integer.parseInt(x)==2){
System.out.println("C");
} else if(Integer.parseInt(x)==3){
System.out.println("D");
}
}
else
System.out.println("C");
z.close();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment