Search is not available for this dataset
name
stringlengths
2
112
description
stringlengths
29
13k
source
int64
1
7
difficulty
int64
0
25
solution
stringlengths
7
983k
language
stringclasses
4 values
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
import java.util.*; import java.lang.*; public class aChildAndHomework { public static void main (String[] args) throws java.lang.Exception { int[] arr = new int[4]; Scanner in = new Scanner(System.in); int min = Integer.MAX_VALUE, max = Integer.MIN_VALUE, minRU = Integer.MAX_VALUE, maxRU = Integer.MIN_VALUE; char mini = 0, maxi = 0; for(int i = 0; i < 4; i++){ String x = in.next(); int j = x.length(); arr[i] = j-2; if(j-2 > max){ maxRU = max; max = j-2; maxi = (char) (i+65); } if (j-2 < min){ minRU = min; min = j-2; mini = (char) (i+65); } } if(minRU == Integer.MAX_VALUE || maxRU == Integer.MIN_VALUE){ int ma = Integer.MIN_VALUE, mi = Integer.MAX_VALUE; for(int i = 0; i<arr.length; i++){ if(arr[i] >= ma && i+65 != maxi){ ma = arr[i]; } if(arr[i] <= mi && i+65 != mini){ mi = arr[i]; } } minRU = mi; maxRU = ma; } if(minRU/2 >= min) { if (maxRU * 2 <= max){ System.out.println('C'); } else System.out.println(mini); } else if (maxRU*2 <= max){ System.out.println(maxi); } else { System.out.println('C'); } } }
JAVA
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
a = [] b = ['A','B','C','D'] a.append(len(raw_input())-2) a.append(len(raw_input())-2) a.append(len(raw_input())-2) a.append(len(raw_input())-2) ans1 = -1 ans2 = -1 for i in xrange(4): cnt = 0 for j in xrange(4): if i != j: if a[i]>=(2*a[j]): cnt += 1 if cnt == 3: ans1 = i for i in xrange(4): cnt = 0 for j in xrange(4): if i != j: if a[i]<=(a[j]/2): cnt += 1 if cnt == 3: ans2=i if ans1 == -1 and ans2 == -1: print b[2] elif ans1 != -1 and ans2 != -1: print b[2] else: print b[max(ans1,ans2)]
PYTHON
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
import java.io.*; import java.util.*; public class A { FastScanner in = new FastScanner(System.in); PrintWriter out = new PrintWriter(System.out); public void run() { String[] s = new String[4]; int[] len = new int[4]; ArrayList<Integer> ans = new ArrayList<Integer>(); for (int i = 0; i < len.length; i++) { s[i] = in.next(); len[i] = s[i].length() - 2; } for (int i = 0; i < 4; i++) { boolean less = true, more = true; for (int j = 0; j < 4; j++) { if (i == j) continue; if (len[i] < len[j] * 2) { more = false; } if (len[i] * 2 > len[j]) { less = false; } } if (less || more) ans.add(i); } if (ans.size() == 1) { System.out.println((char)(ans.get(0) + 'A')); } else { System.out.println("C"); } } public static void main(String[] args) { new A().run(); } public void debug(Object... obj) { System.out.println(Arrays.deepToString(obj)); } class FastScanner { private InputStream stream; private byte[] buf = new byte[1024]; private int curChar; private int numChars; public FastScanner(InputStream stream) { this.stream = stream; //stream = new FileInputStream(new File("dec.in")); } int read() { if (numChars == -1) throw new InputMismatchException(); if (curChar >= numChars) { curChar = 0; try { numChars = stream.read(buf); } catch (IOException e) { throw new InputMismatchException(); } if (numChars <= 0) return -1; } return buf[curChar++]; } boolean isSpaceChar(int c) { return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1; } boolean isEndline(int c) { return c == '\n' || c == '\r' || c == -1; } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } double nextDouble() { return Double.parseDouble(next()); } String next() { int c = read(); while (isSpaceChar(c)) c = read(); StringBuilder res = new StringBuilder(); do { res.appendCodePoint(c); c = read(); } while (!isSpaceChar(c)); return res.toString(); } String nextLine() { int c = read(); while (isEndline(c)) c = read(); StringBuilder res = new StringBuilder(); do { res.appendCodePoint(c); c = read(); } while (!isEndline(c)); return res.toString(); } } }
JAVA
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
#include <bits/stdc++.h> using namespace std; struct Q { int l; char p; } Q[5]; bool cmp(const struct Q &a, const struct Q &b) { return (a.l <= b.l); } int main() { char arr[1000]; char E, F, G, H; scanf("%c%c", &Q[0].p, &E); gets(arr); Q[0].l = strlen(arr); scanf("%c%c", &Q[1].p, &F); gets(arr); Q[1].l = strlen(arr); scanf("%c%c", &Q[2].p, &G); gets(arr); Q[2].l = strlen(arr); scanf("%c%c", &Q[3].p, &H); gets(arr); Q[3].l = strlen(arr); int n = 4; sort(Q, Q + n, cmp); if ((2 * Q[0].l <= (Q[1].l) && 2 * Q[0].l <= (Q[2].l) && 2 * Q[0].l <= (Q[3].l)) && (Q[3].l >= (2 * Q[0].l) && Q[3].l >= (2 * Q[1].l) && Q[3].l >= (2 * Q[2].l))) printf("C"); else if (2 * Q[0].l <= (Q[1].l) && 2 * Q[0].l <= (Q[2].l) && 2 * Q[0].l <= (Q[3].l)) printf("%c", Q[0].p); else if (Q[3].l >= (2 * Q[0].l) && Q[3].l >= (2 * Q[1].l) && Q[3].l >= (2 * Q[2].l)) printf("%c", Q[3].p); else printf("C"); }
CPP
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
import java.util.Scanner; public class A437 { public static void main(String[] args) { Scanner input = new Scanner(System.in); String[] choice = new String[4]; int max = Integer.MIN_VALUE; int min = Integer.MAX_VALUE; for (int i=0; i<4; i++) { String description = input.nextLine().substring(2); int length = description.length(); max = Math.max(length, max); min = Math.min(length, min); choice[i] = description; } boolean minGreat = true; String minCode = null; String maxCode = null; boolean maxGreat = true; for (int i=0; i<4; i++) { int length = choice[i].length(); if (length == min) { if (minCode == null) { minCode = Character.toString((char)('A'+i)); } else { minGreat = false; } } else if (2*min > length) { minGreat = false; } if (length == max) { if (maxCode == null) { maxCode = Character.toString((char)('A'+i)); } else { maxGreat = false; } } else if (max < 2*length) { maxGreat = false; } } if (minGreat) { if (maxGreat) { System.out.println("C"); } else { System.out.println(minCode); } } else { if (maxGreat) { System.out.println(maxCode); } else { System.out.println("C"); } } } }
JAVA
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
a = len(raw_input())-2 b = len(raw_input())-2 c = len(raw_input())-2 d = len(raw_input())-2 dic = {a:'A',b:'B',c:'C',d:'D'} #print dic ar = [a,b,c,d] ar.sort() #print ar if ar[0]*2<=ar[1] and ar[3]<ar[2]*2: print dic[ar[0]] elif ar[3]>=ar[2]*2 and ar[0]*2>ar[1]: print dic[ar[3]] else: print 'C'
PYTHON
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
import java.awt.Point; import java.util.*; public class SinIsh1 { public static void main(String [] args){ Scanner in = new Scanner(System.in); Point array[]=new Point[4]; boolean flag=false; boolean flag1=false; for(int i=0;i<4;i++){ String str=in.next(); array[i]=new Point(str.length()-2,i); } Arrays.sort(array,new solver()); if(2*(array[0].x)<=array[1].x) flag=true; if((array[3].x)>=2*(array[2].x)) flag1=true; if(flag&&!flag1) System.out.println((char)(65+array[0].y)); else if(!flag&&flag1) System.out.println((char)(65+array[3].y)); else System.out.println("C"); } static class solver implements Comparator<Point>{ public int compare(Point a,Point b){ return a.x-b.x; } } }
JAVA
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
def main(): mode="filee" if mode=="file":f=open("test.txt","r") #f.readline() #input() get = lambda :[(f.readline()[:-1] if mode=="file" else input())] a={} for i in range(4): [y]=get() a[chr(65+i)]=len(y[2:]) maxx=max(a.values()) minn=min(a.values()) for i,j in a.items(): if j==minn: minn=[i,j] break for i,j in a.items(): if j==maxx: maxx=[i,j] break found1=True for i,j in a.items(): if minn[1]==j and minn[0]==i: continue if minn[1]*2>j: found1=False break found2=True for i,j in a.items(): if maxx[1]==j and maxx[0]==i: continue if maxx[1]<j*2: found2=False break if (found1 and found2) or (not found1 and not found2): print("C") return elif found1: for i,j in a.items(): if a[i]==minn[1] and i==minn[0]: print(i) return else: for i,j in a.items(): if a[i]==maxx[1] and maxx[0]==i: print(i) return if mode=="file":f.close() if __name__=="__main__": main()
PYTHON3
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
a = input();b = input();c= input();d= input() list = [[len(a)-2,'A'],[len(b)-2,'B'],[len(c)-2,'C'],[len(d)-2,'D']] list.sort() ans = '' t1 = False t2 = False if list[0][0]*2 <= list[1][0]: ans = list[0][1] t1 = True if list[-1][0] >= list[-2][0]*2: ans = list[-1][1] t2 = True if (t1 and t2) or t1 == False and t2 == False: ans = 'C' print(ans)
PYTHON3
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner input = new Scanner(System.in); String[] choices = new String[4]; for (int i = 0; i < 4; i++) { String line = input.nextLine(); choices[i] = line.substring(2); } int count = 0; int result = -1; for (int i = 0; i < 4; i++) { int len = choices[i].length(); boolean shorter = true; boolean longer = true; for (int j = 0; j < 4; j++) if (i != j) { if (len < choices[j].length() * 2) longer = false; if (len * 2 > choices[j].length()) shorter = false; } if (longer || shorter) { count ++; result = i; } } if (count == 1) System.out.println((char)((int)('A') + result)); else System.out.println("C"); } }
JAVA
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; public class ChildAndHomeWork{ //CF 437A div1 public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out)); String [] option = new String [4]; option[0] = br.readLine().substring(2); option[1]= br.readLine().substring(2); option[2] = br.readLine().substring(2); option[3] = br.readLine().substring(2); int shorterOption = -1; int tallerOption = -1; for(int i=0;i<4;i++) { boolean isShorter = true; for(int j=0;j<4;j++) { if(i!=j &&option[i].length()>option[j].length()/2) { isShorter =false; break; } } if(isShorter) { shorterOption = i; break; } } for(int i=0;i<4;i++) { boolean isTaller= true; for(int j=0;j<4;j++) { if(i!=j &&option[i].length()<option[j].length()*2) { isTaller =false; break; } } if(isTaller) { tallerOption = i; break; } } if((tallerOption != -1 && shorterOption != -1)|| (tallerOption==-1 && shorterOption==-1)) System.out.println("C"); else if(tallerOption != -1) System.out.println((char)('A'+tallerOption)); else System.out.println((char)('A'+shorterOption)); } }
JAVA
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.IOException; import java.util.Arrays; import java.util.StringTokenizer; import static java.lang.Math.max; import static java.lang.Math.min; import static java.lang.Math.abs; import static java.lang.Math.floor; import static java.lang.Math.ceil; /* ------------ Theorems and Lemmas ------------ */ // Fermat's Little Theorem // (1) ((a ** p) - a) % p = 0; if 'p' is prime // (2) Further, if 'a % p != 0', then ((a ** (p - 1)) - 1) % p = 0 /* -------------- End of theorems -------------- */ public class Solution { // Digit DP private static int digit; private static int times; private static StringBuilder number; private static int[][][] digitDP; // End public static void main(String[] args) { class Pair { char choice; int len; public Pair(char choice, int len) { this.choice = choice; this.len = len; } } FastReader reader = new FastReader(); Pair[] pairs = new Pair[4]; for (int i = 0; i < 4; ++i) { String[] temp = reader.nextLine().replace(".", " ").split("\\s+"); pairs[i] = new Pair((char) (i + 'A'), temp[1].length()); } reader.close(); Arrays.sort(pairs, (p1, p2) -> p1.len - p2.len); if (pairs[0].len * 2 <= pairs[1].len && pairs[3].len >= pairs[2].len * 2) System.out.println("C"); else if (pairs[0].len * 2 <= pairs[1].len) System.out.println(pairs[0].choice); else if (pairs[3].len >= pairs[2].len * 2) System.out.println(pairs[3].choice); else System.out.println("C"); } // Digit DP public static int ddp(int n) { number = new StringBuilder(String.valueOf(n)); digitDP = new int[12][12][2]; for (int[][] a : digitDP) for (int[] b : a) Arrays.fill(b, -1); return call(0, 0, 0); } // Digit DP public static int call(int pos, int cnt, int f) { if (cnt > times) return 0; if (pos == number.length()) return cnt == times ? 1 : 0; if (digitDP[pos][cnt][f] != -1) return digitDP[pos][cnt][f]; int res = 0; int lmt = f == 0 ? number.charAt(pos) - '0' : 9; for (int dgt = 0; dgt <= lmt; ++dgt) if ((dgt == digit ? 1 + cnt : cnt) <= times) res += call(1 + pos, dgt == digit ? 1 + cnt : cnt, f == 0 && dgt < lmt ? 1 : f); digitDP[pos][cnt][f] = res; return res; } // Binary Exponentiation public static long binpow(long a, long n, long mod) { // Iterative approach a %= mod; long result = 1l; while (n > 0l) { if ((n & 1l) != 0l) result = result * a % mod; a = a * a % mod; n >>= 1l; } return result; // Recursive approach /* * if (n == 0l) return 1l; long res = binpow(a, n / 2, mod); if ((n & 1l) != 0l) * return ((res % mod) * (res % mod) * (a % mod)) % mod; else return ((res % * mod) * (res % mod)) % mod; */ } // GCD public static long gcd(long a, long b) { while (b > 0) { a %= b; long t = a; a = b; b = t; } return a; } static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreElements()) { try { st = new StringTokenizer(br.readLine().trim()); } catch (IOException e) { e.printStackTrace(); } } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } float nextFloat() { return Float.parseFloat(next()); } double nextDouble() { return Double.parseDouble(next()); } String nextLine() { StringBuilder str = new StringBuilder(""); try { str.append(br.readLine().trim()); } catch (IOException e) { e.printStackTrace(); } return str.toString(); } int[] readArray(int size) { int[] ar = new int[size]; for (int i = 0; i < size; ++i) ar[i] = nextInt(); return ar; } void close() { try { br.close(); } catch (IOException e) { e.printStackTrace(); } } } }
JAVA
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
import java.io.IOException; import java.io.OutputStreamWriter; import java.util.Arrays; import java.io.BufferedWriter; import java.util.InputMismatchException; import java.io.OutputStream; import java.io.PrintWriter; import java.util.NoSuchElementException; import java.io.Writer; import java.math.BigInteger; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * @author Chau Tuan Kiet - [email protected] */ public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); OutputWriter out = new OutputWriter(outputStream); TaskA solver = new TaskA(); solver.solve(1, in, out); out.close(); } } class TaskA { public void solve(int testNumber, InputReader in, OutputWriter out) { Pair<Integer, Integer> [] res = new Pair[4]; for(int i = 0; i < 4; i++){ String s = in.readString(); res[i] = new Pair<Integer, Integer> (s.length() - 2, i); } Arrays.sort(res); int choose = 0; int pos = 0; if(2 * res[0].first <= res[1].first){ choose = 1; pos = res[0].second; } if(res[3].first >= 2*res[2].first){ choose += 1; pos = res[3].second; } if(choose == 0 || choose == 2) out.printLine("C"); else out.printLine((char)('A' + pos)); } } class InputReader { private InputStream stream; private byte[] buf = new byte[1024]; private int curChar; private int numChars; private SpaceCharFilter filter; public InputReader(InputStream stream) { this.stream = stream; } public int read() { if (numChars == -1) throw new InputMismatchException(); if (curChar >= numChars) { curChar = 0; try { numChars = stream.read(buf); } catch (IOException e) { throw new InputMismatchException(); } if (numChars <= 0) return -1; } return buf[curChar++]; } public String readString() { int c = read(); while (isSpaceChar(c)) c = read(); StringBuilder res = new StringBuilder(); do { if (Character.isValidCodePoint(c)) res.appendCodePoint(c); c = read(); } while (!isSpaceChar(c)); return res.toString(); } public boolean isSpaceChar(int c) { if (filter != null) return filter.isSpaceChar(c); return isWhitespace(c); } public static boolean isWhitespace(int c) { return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1; } public interface SpaceCharFilter { public boolean isSpaceChar(int ch); } } class OutputWriter { private final PrintWriter writer; public OutputWriter(OutputStream outputStream) { writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream))); } public void print(Object...objects) { for (int i = 0; i < objects.length; i++) { if (i != 0) writer.print(' '); writer.print(objects[i]); } } public void printLine(Object...objects) { print(objects); writer.println(); } public void printLine(char i) { writer.println(i); } public void close() { writer.close(); } } class Pair<U, V> implements Comparable<Pair<U, V>> { public final U first; public final V second; public Pair(U first, V second) { this.first = first; this.second = second; } public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Pair pair = (Pair) o; return !(first != null ? !first.equals(pair.first) : pair.first != null) && !(second != null ? !second.equals(pair.second) : pair.second != null); } public int hashCode() { int result = first != null ? first.hashCode() : 0; result = 31 * result + (second != null ? second.hashCode() : 0); return result; } public String toString() { return "(" + first + "," + second + ")"; } public int compareTo(Pair<U, V> o) { int value = ((Comparable<U>)first).compareTo(o.first); if (value != 0) return value; return ((Comparable<V>)second).compareTo(o.second); } }
JAVA
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
import java.util.*; import java.io.*; public class a437 { /************************ SOLUTION STARTS HERE ************************/ //DONT FORGET TO COMMIT AND PUSH TO GITHUB private static void solve(FastScanner s1, FastWriter out){ String a[]=new String[4]; int len[]=new int[4]; for(int i=0;i<4;i++){ a[i]=s1.nextLine(); len[i]=a[i].length()-2; } boolean tS=false,tT=false; char minA='C',maxA='C'; int min[]=new int[2]; min[1]=min[0]=100; int max[]=new int[2]; for(int i=0;i<4;i++){ if(len[i]<min[0]){ min[1]=min[0]; min[0]=len[i]; minA=(char) (i+'A'); } else if(len[i]<min[1]){ min[1]=len[i]; } if(len[i]>max[0]){ max[1]=max[0]; max[0]=len[i]; maxA=(char) (i+'A'); } else if(len[i]>max[1]){ max[1]=len[i]; } } if((min[0])<=min[1]/2){ tS=true; //out.println(min[0]+" "+min[1]); } if(max[0]>=2*max[1]){ tT=true; //out.println(max[0]+" "+max[1]); } if(tS&&tT||(!(tS||tT))){ out.print('C'); } else if(tS){ out.print(minA);; } else{ out.print(maxA);; } } /************************ SOLUTION ENDS HERE ************************/ /************************ TEMPLATE STARTS HERE ************************/ public static void main(String []args) throws IOException { FastScanner in = new FastScanner(System.in); FastWriter out = new FastWriter(System.out); solve(in, out); in.close(); out.close(); } static class FastScanner{ public BufferedReader reader; public StringTokenizer st; public FastScanner(InputStream stream){ reader = new BufferedReader(new InputStreamReader(stream)); st = null; } public String next(){ while(st == null || !st.hasMoreTokens()){ try{ String line = reader.readLine(); if(line == null) return null; st = new StringTokenizer(line); }catch (Exception e){ throw (new RuntimeException()); } } return st.nextToken(); } public String nextLine(){ String str = null; try { str = reader.readLine(); } catch (IOException e) { e.printStackTrace(); } return str; } public int nextInt(){ return Integer.parseInt(next()); } public long nextLong(){ return Long.parseLong(next()); } public double nextDouble(){ return Double.parseDouble(next()); } int[] nextIntArray(int n) { int[] arr = new int[n]; for (int i = 0; i < n; i++) { arr[i] = nextInt(); } return arr; } long[] nextLongArray(int n) { long[] arr = new long[n]; for (int i = 0; i < n; i++) { arr[i] = nextLong(); } return arr; } public void close(){ try{ reader.close(); } catch(IOException e){e.printStackTrace();} } } static class FastWriter{ BufferedWriter writer; public FastWriter(OutputStream stream){ writer = new BufferedWriter(new OutputStreamWriter(stream)); } public void print(int i) { print(Integer.toString(i)); } public void println(int i) { print(Integer.toString(i)); print('\n'); } public void print(long i) { print(Long.toString(i)); } public void println(long i) { print(Long.toString(i)); print('\n'); } public void print(double i) { print(Double.toString(i)); } public void print(boolean i) { print(Boolean.toString(i)); } public void print(char i) { try{writer.write(i);} catch(IOException e){e.printStackTrace();} } public void print(String s){ try{writer.write(s);} catch(IOException e){e.printStackTrace();} } public void println(String s){ try{writer.write(s);writer.write('\n');} catch(IOException e){e.printStackTrace();} } public void println(){ try{writer.write('\n');} catch(IOException e){e.printStackTrace();} } public void print(int arr[]) { for (int i = 0; i < arr.length; i++) { print(arr[i]); print(' '); } } public void close(){ try{writer.close();} catch(IOException e){e.printStackTrace();} } } /************************ TEMPLATE ENDS HERE ************************/ }
JAVA
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
#include <bits/stdc++.h> using namespace std; vector<pair<int, char> > V; map<char, int> A; int main() { string x; cin >> x; V.push_back(make_pair(x.size() - 2, 'A')); cin >> x; V.push_back(make_pair(x.size() - 2, 'B')); cin >> x; V.push_back(make_pair(x.size() - 2, 'C')); cin >> x; V.push_back(make_pair(x.size() - 2, 'D')); int l = 0; sort(V.begin(), V.end()); if (V[3].first >= V[2].first * 2) l++; if (V[0].first * 2 <= V[1].first) l += 2; if (l == 1) cout << V[3].second; else if (l == 2) cout << V[0].second; else cout << 'C'; return 0; }
CPP
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
a=len(input())-2 b=len(input())-2 c=len(input())-2 d=len(input())-2 ans='' if (a*2<=b and a*2<=c and a*2<=d) or (b*2<=a and c*2<=a and d*2<=a): ans+='A' if (b*2<=a and b*2<=c and b*2<=d) or (a*2<=b and c*2<=b and d*2<=b): ans+='B' if (c*2<=b and c*2<=a and c*2<=d) or (b*2<=c and a*2<=c and d*2<=c): ans+='C' if (d*2<=b and d*2<=c and d*2<=a) or (b*2<=d and c*2<=d and a*2<=d): ans+='D' if len(ans)==1: print(ans) else: print('C')
PYTHON3
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
import java.util.Scanner; import java.util.stream.IntStream; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String[] descriptions = new String[4]; for (int i = 0; i < descriptions.length; i++) { descriptions[i] = sc.next().substring(2); } System.out.println(solve(descriptions)); sc.close(); } static char solve(String[] descriptions) { int[] candidateIndices = IntStream.range(0, descriptions.length) .filter(i -> IntStream.range(0, descriptions.length) .allMatch(j -> j == i || descriptions[j].length() >= descriptions[i].length() * 2) || IntStream.range(0, descriptions.length) .allMatch(j -> j == i || descriptions[j].length() * 2 <= descriptions[i].length())) .toArray(); return (candidateIndices.length == 1) ? (char) (candidateIndices[0] + 'A') : 'C'; } }
JAVA
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
import java.util.ArrayList; import java.util.Comparator; import java.util.List; import java.util.Scanner; public class A_The_Child_And_Homework { public static void main(String[] args) { // TODO Auto-generated method stub Scanner input = new Scanner(System.in); List<String> l = new ArrayList<>(4); l.add(input.nextLine().substring(2)); l.add(input.nextLine().substring(2)); l.add(input.nextLine().substring(2)); l.add(input.nextLine().substring(2)); List<String> lC = new ArrayList<>(l); l.sort(Comparator.comparing(String::length)); int res = 2; boolean fait = false; if(l.get(0).length() * 2 <= l.get(1).length()) { res = lC.indexOf(l.get(0)); fait = true; } if(l.get(3).length() >= l.get(2).length() * 2) { if(!fait) { res = lC.indexOf(l.get(3)); } else { res = 2; } } switch(res) { case 0 : System.out.println("A"); break; case 1 : System.out.println("B"); break; case 2 : System.out.println("C"); break; case 3 : System.out.println("D"); break; } input.close(); } }
JAVA
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
import java.util.*; import java.io.*; public class Main { public static void main(String[] args) throws Exception { Scanner in = new Scanner(System.in); boolean aGreat, bGreat, cGreat, dGreat; int aLength, bLength, cLength, dLength; aLength = in.next().length() - 2; bLength = in.next().length() - 2; cLength = in.next().length() - 2; dLength = in.next().length() - 2; aGreat = TestForGreatness(aLength, bLength, cLength, dLength); bGreat = TestForGreatness(bLength, aLength, cLength, dLength); cGreat = TestForGreatness(cLength, bLength, aLength, dLength); dGreat = TestForGreatness(dLength, bLength, cLength, aLength); int answer; if (aGreat && !(bGreat || cGreat || dGreat)) answer = 0; else if (bGreat && !(aGreat || cGreat || dGreat)) answer = 1; else if (dGreat && !(aGreat || bGreat || cGreat)) answer = 3; else answer = 2; switch (answer) { case 0: System.out.print("A"); break; case 1: System.out.print("B"); break; case 2: System.out.print("C"); break; case 3: System.out.print("D"); break; } } public static boolean TestForGreatness(int test, int v0, int v1, int v2) { return (test <= v0 / 2 && test <= v1 / 2 && test <= v2 / 2) || (test >= v0 * 2 && test >= v1 * 2 && test >= v2 * 2); } }
JAVA
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
#include <bits/stdc++.h> using namespace std; int main() { string a, b, c, d; cin >> a >> b >> c >> d; int la = a.size() - 2, lb = b.size() - 2, lc = c.size() - 2, ld = d.size() - 2, fa = 0, fb = 0, fc = 0, fd = 0; if ((2 * la <= lb && 2 * la <= lc && 2 * la <= ld) || (la >= 2 * lb && la >= 2 * lc && la >= 2 * ld)) fa = 1; if ((2 * lb <= la && 2 * lb <= lc && 2 * lb <= ld) || (lb >= 2 * la && lb >= 2 * lc && lb >= 2 * ld)) fb = 1; if ((2 * lc <= la && 2 * lc <= lb && 2 * lc <= ld) || (lc >= 2 * la && lc >= 2 * lb && lc >= 2 * ld)) fc = 1; if ((2 * ld <= la && 2 * ld <= lb && 2 * ld <= lc) || (ld >= 2 * la && ld >= 2 * lb && ld >= 2 * lc)) fd = 1; if ((fa) && (!(fb)) && (!(fc)) && (!(fd))) cout << "A\n"; else if ((!(fa)) && (fb) && (!(fc)) && (!(fd))) cout << "B\n"; else if ((!(fa)) && (!(fb)) && (!(fc)) && (fd)) cout << "D\n"; else cout << "C\n"; return 0; }
CPP
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
#include <bits/stdc++.h> using namespace std; int main() { string second[4]; for (long long i = 0; i < 4; i++) cin >> second[i]; long long a[4] = {0}; a[0] = second[0].length() - 2; a[1] = second[1].length() - 2; a[2] = second[2].length() - 2; a[3] = second[3].length() - 2; long long cnt = 0; long long ans1 = -1; map<long long, char> m; m[0] = 'A'; m[1] = 'B'; m[2] = 'C'; m[3] = 'D'; for (long long i = 0; i < 4; i++) { cnt = 0; for (long long j = 0; j < 4; j++) { if (i != j) { if (2 * a[i] <= a[j]) { cnt++; } } } if (cnt == 3) ans1 = i; } long long ans2 = -1; for (long long i = 0; i < 4; i++) { cnt = 0; for (long long j = 0; j < 4; j++) { if (i != j) { if (a[i] >= 2 * a[j]) { cnt++; } } } if (cnt == 3) ans2 = i; } if ((ans1 == -1 && ans2 == -1) || (ans1 >= 0 && ans2 >= 0)) cout << "C" << "\n"; else { if (ans1 >= 0) cout << m[ans1] << "\n"; else cout << m[ans2] << "\n"; } return 0; }
CPP
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
z=[len(input()[2:]) for _ in " "*4] s,g=-1,-1 for i in range(4): ok=1 for j in range(4): if i!=j and 2*z[i]>z[j]:ok=0 if ok:s=i for i in range(4): ok=1 for j in range(4): if i!=j and z[i]<2*z[j]:ok=0 if ok:g=i if s!=-1 and g!=-1:print("C") elif s!=-1:print(chr(65+s)) elif g!=-1:print(chr(65+g)) else:print("C")
PYTHON3
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
import java.util.Scanner; import java.util.TreeMap; public class test { public static void main(String args[]){ Scanner s=new Scanner(System.in); String a=s.next(); String b=s.next(); String c=s.next(); String d=s.next(); int al=a.length()-2; int bl=b.length()-2; int cl=c.length()-2; int dl=d.length()-2; int cnt=0;int aaa[]=new int[4]; if((2*al<=bl && 2*al<=cl && 2*al<=dl)|| (al>=2*bl && al>=2*cl && al>=2*dl)){ cnt++; aaa[0]=1; } if((2*bl<=al && 2*bl<=cl && 2*bl<=dl)|| (bl>=2*al && bl>=2*cl && bl>=2*dl)){ cnt++; aaa[1]=1; } if((2*cl<=bl && 2*cl<=al && 2*cl<=dl)|| (cl>=2*bl && cl>=2*al && cl>=2*dl)){ cnt++; aaa[2]=1; } if((2*dl<=bl && 2*dl<=cl && 2*dl<=al)|| (dl>=2*bl && dl>=2*cl && dl>=2*al)){ cnt++; aaa[3]=1; } if(cnt>1 || cnt==0){System.out.println("C");} else { if(aaa[0]==1){System.out.println("A");} if(aaa[1]==1){System.out.println("B");} if(aaa[2]==1){System.out.println("C");} if(aaa[3]==1){System.out.println("D");} } } }
JAVA
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
/** * @(#)HomeWork.java * * * @author Suyash Bhalla * @version 1.00 2016/6/15 */ import java.io.*; public class HomeWork { public static void main(String args[])throws IOException{ BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); String a=br.readLine(); int alen=a.length()-2; String b=br.readLine(); int blen=b.length()-2; String c=br.readLine(); int clen=c.length()-2; String d=br.readLine(); int dlen=d.length()-2; int cnt=0; char ans='C'; if((alen<=(blen/2)&&alen<=(clen/2)&&alen<=(dlen/2))|| (alen>=(2*blen)&&alen>=(2*clen)&&alen>=(2*dlen))){ ans='A'; cnt++; } if((blen<=(alen/2)&&blen<=(clen/2)&&blen<=(dlen/2))|| (blen>=(2*alen)&&blen>=(2*clen)&&blen>=(2*dlen))){ ans='B'; cnt++; } if((clen<=(blen/2)&&clen<=(alen/2)&&clen<=(dlen/2))|| (clen>=(2*blen)&&clen>=(2*alen)&&clen>=(2*dlen))){ ans='C'; cnt++; } if((dlen<=(blen/2)&&dlen<=(clen/2)&&dlen<=(alen/2))|| (dlen>=(2*blen)&&dlen>=(2*clen)&&dlen>=(2*alen))){ ans='D'; cnt++; } if(cnt==1){ System.out.println(ans); }else{ System.out.println('C'); } } }
JAVA
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
p = [raw_input().split('.') for _ in xrange(4)] p = sorted([(len(x[1]), x[0]) for x in p]) ans = [] if (p[0][0] * 2 <= p[1][0]): ans.append(p[0][1]) if (p[-1][0] >= p[-2][0] * 2): ans.append(p[-1][1]) if len(ans) == 1: print ans[0] else: print "C"
PYTHON
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
import java.io.IOException; import java.text.ParseException; import java.util.ArrayList; import java.util.List; import java.util.Scanner; public class A { private static final int SIZE = 4; public static void main(String[] args) throws IOException, ParseException { new A().doJob(); } private void doJob() throws ParseException, IOException { try (Scanner scanner = new Scanner(System.in)) { int maxLength = 0; String maxAnswer = ""; int minLength = 101; String minAnswer = ""; int lengths[] = new int[SIZE]; for (int i = 0; i < SIZE; i++) { String answer = scanner.next(); int size = answer.length() - 2; if (maxLength < size) { maxLength = size; maxAnswer = answer.substring(0, 1); } if (size < minLength) { minLength = size; minAnswer = answer.substring(0, 1); } lengths[i] = size; } List<Integer> bestAnswers = new ArrayList<>(4); int minLengthCount = 0; int maxLengthCount = 0; for (int i = 0; i < lengths.length; i++) { int size = lengths[i]; if (minLength <= size / 2.0) { minLengthCount++; } if (maxLength >= size * 2.0) { maxLengthCount++; } } String answer = "C"; if (maxLengthCount < minLengthCount && minLengthCount == 3) { answer = minAnswer; } if (maxLengthCount > minLengthCount && maxLengthCount == 3) { answer = maxAnswer; } System.out.println(answer); } } }
JAVA
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
#include <bits/stdc++.h> using namespace std; int main() { string s; pair<int, string> p[4]; for (int i = 0; i < 4; i++) { cin >> s; p[i] = make_pair(s.length() - 2, s); } sort(p, p + 4); int b = -1; if (p[1].first / 2 >= p[0].first) b = 0; if (p[3].first / 2 >= p[2].first) { if (b == 0) b = -1; else b = 3; } if (b == -1) cout << "C"; else cout << p[b].second[0]; return 0; }
CPP
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
a = raw_input()[2:] b = raw_input()[2:] c = raw_input()[2:] d = raw_input()[2:] al = len(a) bl = len(b) cl = len(c) dl = len(d) arr = [0,0,0,0] ans = ['A','B','C','D'] if al>=2*(max(bl,cl,dl)) or al*2<= (min(bl,cl,dl)): arr[0]+=1 if bl>=2*(max(al,cl,dl)) or bl*2<= (min(al,cl,dl)): arr[1]+=1 if cl>=2*(max(bl,al,dl)) or cl*2<= (min(bl,al,dl)): arr[2]+=1 if dl>=2*(max(bl,cl,al)) or dl*2<= (min(bl,cl,al)): arr[3]+=1 if arr.count(1)==1: print ans[arr.index(1)] else: print 'C'
PYTHON
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
#include <bits/stdc++.h> using namespace std; int main() { vector<pair<long long int, long long int> > v; vector<long long int> gt; for (int i = 0; i < 4; i++) { string s; cin >> s; v.push_back({s.size() - 2, i + 1}); } sort(v.begin(), v.end()); if (v[0].first * 2 <= v[1].first) gt.push_back(v[0].second); if (v[2].first * 2 <= v[3].first) gt.push_back(v[3].second); if (gt.size() == 1) { if (gt[0] == 1) cout << 'A' << endl; else if (gt[0] == 2) cout << 'B' << endl; else if (gt[0] == 3) cout << 'C' << endl; else cout << 'D' << endl; } else cout << 'C' << endl; return 0; }
CPP
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
# /** # * Ashesh Vidyut (Drift King) * # */ sta = str(raw_input())[2:] stb = str(raw_input())[2:] stc = str(raw_input())[2:] std = str(raw_input())[2:] lena = len(sta) lenb = len(stb) lenc = len(stc) lend = len(std) ansa = False ansb = False ansc = False ansd = False if lena <= float(lenb)/2 and lena <= float(lenc)/2 and lena <= float(lend)/2: ansa = True; if lenb <= float(lena)/2 and lenb <= float(lenc)/2 and lenb <= float(lend)/2: ansb = True; if lenc <= float(lena)/2 and lenc <= float(lenb)/2 and lenc <= float(lend)/2: ansc = True; if lend <= float(lena)/2 and lend <= float(lenb)/2 and lend <= float(lenc)/2: ansd = True; if lena >= float(lenb)*2 and lena >= float(lenc)*2 and lena >= float(lend)*2: ansa = True; if lenb >= float(lena)*2 and lenb >= float(lenc)*2 and lenb >= float(lend)*2: ansb = True; if lenc >= float(lena)*2 and lenc >= float(lenb)*2 and lenc >= float(lend)*2: ansc = True; if lend >= float(lena)*2 and lend >= float(lenb)*2 and lend >= float(lenc)*2: ansd = True; if ansa and not ansb and not ansc and not ansd: print "A"; elif ansb and not ansa and not ansc and not ansd: print "B"; elif ansc and not ansa and not ansb and not ansd: print "C"; elif ansd and not ansa and not ansb and not ansc: print "D"; else: print "C"
PYTHON
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
l = [input() for _ in range(4)] m = list(map(lambda x : len(x[2:]),l)) res = [] for i in l : y = 1 r1 = True r2 = True for j in l : if i != j : if (len(i[2:]) >= len(j[2:])*2) and r1 : y *= 1 r2 = False elif (len(i[2:]) <= len(j[2:])/2) and r2: r1 = False y *= 1 else : y *= 0 break res.append(y) if res.count(0) == 4 : print('C') elif res.count(1) > 1 : print('C') else: print('ABCD'[res.index(1)])
PYTHON3
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
import java.util.Scanner; public class The_Child_and_Homework { public static void main(String args[]){ Scanner in = new Scanner(System.in); String s[] = new String[4]; for(int i = 0 ; i < 4 ; i++) s[i] = in.next(); double len[] = new double[4]; for(int i= 0 ; i < 4 ; i++) len[i] = s[i].length() - 2; //System.out.println("a = "+len[0]+" b = "+len[1]+" c = "+ len[2]+" d = "+len[3]); System.out.println(Check(len[0],len[1],len[2],len[3])); } static String Check(double a , double b , double c , double d){ double ch = 0 ; String s = ""; if(a<=(b/2)&&a<=(c/2)&&a<=(d/2)){ ch++; s = "A"; } if(b<=(a/2)&&b<=(c/2)&&b<=(d/2)){ ch++; s = "B"; } if(c<=(a/2)&&c<=(b/2)&&c<=(d/2)){ ch++; s = "C"; } if(d<=(a/2)&&d<=(b/2)&&d<=(c/2)){ ch++; s = "D"; } if(ch==2){ return "C"; }else{ String temp = ""; if(ch == 1) temp = s ; ch = 0; s = ""; if(a/2>=b&&a/2>=c&&a/2>=d){ ch++; s = "A"; } if(b/2>=a&&b/2>=c&&b/2>=d){ ch++; s = "B"; } if(c/2>=a&&c/2>=b&&c/2>=d){ ch++; s = "C"; } if(d/2>=a&&d/2>=b&&d/2>=c){ ch++; s = "D"; } if(ch == 1&&temp.equals("")){ return s; }else if(ch!=1&&temp.equals("")==false){ return temp; }else if(ch == 2){ return "C"; }else{ return "C"; } } } }
JAVA
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
var a = readline() var b = readline() var c = readline() var d = readline() lena = a.substring(2).length lenb = b.substring(2).length lenc = c.substring(2).length lend = d.substring(2).length var letters = ["A", "B", "C", "D"] var lengths = [lena, lenb, lenc, lend] var great = false var greatLetter = "A" var numGreat = 0 var numLonger = 0 var numShorter = 0 for (var i = 0; i < 4; i++){ numShorter = 0 numLonger = 0 for (var j = 0; j <4; j++){ if(i !== j){ if(lengths[i] > lengths[j]){ if(lengths[i] >= 2*lengths[j]){ numLonger++ great = true } else{ great = false break } } else{ if(2* lengths[i] <= lengths[j]){ numShorter++ great = true } else{ great = false break } } } } if(great === true && ((numLonger === 0) || (numShorter === 0)) ){ greatLetter = letters[i] numGreat++ } } if(numGreat !== 1){ print("C") } else{ print(greatLetter) }
JAVA
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
choices = [len(raw_input()[2:]) for i in xrange(4)] answers = [] for i in xrange(4): c, d = [], [] for j in xrange(4): if i == j: continue a = choices[i] b = choices[j] if a >= 2 * b: c.append(j) if a <= b / 2: d.append(j) if len(c) == 3 or len(d) == 3: answers.append(chr(i + ord('A'))) if len(answers) == 1: print ''.join(answers) else: print 'C'
PYTHON
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); vector<int> v(4, 0); int cnt = 0; for (int i = 0; i < 4; i++) { string s; cin >> s; v[i] += s.length() - 2; } char ch = 'C'; int ans = 0; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { if (i != j) { if (v[i] >= 2 * v[j]) { cnt++; } if (2 * v[i] <= v[j]) { cnt--; } } } if (cnt == 3 || cnt == -3) { ch = (char)(65 + i); ans++; } cnt = 0; } if (ans != 1) { cout << "C\n"; } else { cout << ch << "\n"; } return 0; }
CPP
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
function trim(s) { return s.replace(/^\s+|\s+$/gm, ''); } function tokenize(s) { return trim(s).split(/\s+/); } function tokenizeIntegers(s) { var tokens = tokenize(s); for (var i = 0; i < tokens.length; i += 1) { tokens[i] = parseInt(tokens[i], 10); }; return tokens; } function main() { var info = []; for (var i = 0; i < 4; ++i) { var line = trim(readline()); info.push({ choice: line.charAt(0), length: line.length - 2 }); } info.sort(function (a, b) { return a.length - b.length; }); var superShort = info[0].length*2 <= info[1].length, superLong = info[3].length >= 2*info[2].length; if (superShort ^ superLong) { if (superShort) { print(info[0].choice); } else { print(info[3].choice); } } else { print('C'); } } main();
JAVA
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
from sys import stdin a=stdin.readlines() hi = 0 b=[] for i in a: j=i.strip().split('.')[1] if len(j)>hi: hi = len(j) b.append(len(j)) lo = b[0] for i in b: if i<lo: lo = i #print lo,hi #print b ans = ['A','B','C','D'] fir = 0 sec = 0 resm=resh=0 for i in xrange(len(b)): if b[i]==lo: resm=i if b[i]==hi: resh=i if 2*lo <=b[i]: fir+=1 if hi>=2*b[i]: sec+=1 if fir==3 and sec==3: print "C" elif fir==3: print ans[resm] elif sec==3: print ans[resh] else: print "C"
PYTHON
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
#include <bits/stdc++.h> int main() { int i, j, l[4]; char s[105]; int n1, n2; int f, c = 0; for (i = 1; i <= 4; i++) { scanf("%s", &s); l[i] = strlen(s) - 2; } for (i = 1; i <= 4; i++) { n1 = 0; n2 = 0; for (j = 1; j <= 4; j++) { if (i != j) { if (l[i] <= l[j] / 2) n1++; else if (l[i] >= 2 * l[j]) n2++; } } if (n1 == 3 || n2 == 3) { c++; f = i - 1; } } if (c == 1) printf("%c\n", 'A' + f); else printf("%c\n", 'C'); return 0; }
CPP
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
import java.math.BigInteger; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.Queue; import java.util.Scanner; import java.util.Set; import java.util.TreeSet; public class ACM { static boolean v[][]; static int ar[][]; static int w = 8; static int h = 8; static int dr[] = { -2, -2, -1, 1, 2, 2, 1, -1 }; static int dc[] = { -1, 1, 2, 2, 1, -1, -2, -2 }; static Queue<Pair> q; static int cost[][]; public static void main(String[] args) { Scanner in = new Scanner(System.in); HashMap<Character, Integer> map = new HashMap<Character, Integer>(); for (int i = 0; i < 4; i++) { String str = in.nextLine(); char key = str.charAt(0); int discLen = str.substring(2, str.length()).length(); map.put(key, discLen); } String choices = "ABCD"; ArrayList<Character> answers = new ArrayList<Character>(); for (int i = 0; i < choices.length(); i++) { int lessThan = 0 ; int greaterThan = 0; char selectedChoice = choices.charAt(i); for (int j = 0; j < choices.length(); j++) { if(selectedChoice==choices.charAt(j)) continue; if(map.get(selectedChoice)<=map.get(choices.charAt(j))/2) lessThan++; else if(map.get(selectedChoice)>=map.get(choices.charAt(j))*2) greaterThan++; } if(lessThan==3) answers.add(selectedChoice); if(greaterThan==3) answers.add(selectedChoice); } if(answers.size()==1) System.out.println(answers.get(0)); else System.out.println("C"); } private static void BFS(int r, int c, int tr, int tc) { q.add(new Pair(r, c)); cost[r][c] = 0; while (!q.isEmpty()) { r = q.peek().x; c = q.peek().y; q.poll(); if (r == tr && c == tc) break; for (int i = 0; i < 8; ++i) { int nr = r + dr[i]; int nc = c + dc[i]; if (!valid(nr, nc)) continue; cost[nr][nc] = cost[r][c] + 1; q.add(new Pair(nr, nc)); } } } static boolean valid(int r, int c) { if (r < 0 || r >= h || c < 0 || c >= w) return false; if (v[r][c]) return false; return true; } } class Pair { int x, y; public Pair(int x, int y) { this.x = x; this.y = y; } } class QueueOmar { int first = -1 , last = -1 , size = 0 ; int ar[]; public QueueOmar(int n){ ar = new int [n+100]; } public void add(int n){ size++; ar[++last] = n; } public int poll(){ size--; return ar[++first]; } public boolean isEmpty (){ return first == last; } }
JAVA
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
#include <bits/stdc++.h> using namespace std; string k[] = {"A", "B", "C", "D"}; int len[5]; int mn = 500; int cnt, cnt2; int mx = -500; int posmn, posmx; int main() { ios_base::sync_with_stdio(0); string a[5]; for (int i = 1; i <= 4; ++i) { cin >> a[i]; len[i] = a[i].length() - 2; mn = min(mn, len[i]); if (mn == len[i]) posmn = i; mx = max(mx, len[i]); if (mx == len[i]) posmx = i; } for (int i = 1; i <= 4; ++i) { if (mn * 2 <= len[i]) ++cnt; if (mx >= 2 * len[i]) ++cnt2; } if (cnt == 3 && cnt2 == 3) cout << "C"; else if (cnt == 3) cout << k[posmn - 1]; else if (cnt2 == 3) cout << k[posmx - 1]; else cout << "C"; }
CPP
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
import java.util.*; import java.io.*; public class A { Reader in; PrintWriter out; int i = 0, j = 0; void solve() { //START// int[] desc = new int[4]; for (i = 0; i < 4; i++) { desc[i] = in.next().length()-2; } int choices = 0; char ch = 'C'; if ((desc[0]*2 <= desc[1] && desc[0]*2 <= desc[2] && desc[0]*2 <= desc[3]) || (desc[0]/2 >= desc[1] && desc[0]/2 >= desc[2] && desc[0]/2 >= desc[3])) { choices++; ch = 'A'; } if ((desc[1]*2 <= desc[0] && desc[1]*2 <= desc[2] && desc[1]*2 <= desc[3]) || (desc[1]/2 >= desc[0] && desc[1]/2 >= desc[2] && desc[1]/2 >= desc[3])) { choices++; ch = 'B'; } if ((desc[2]*2 <= desc[1] && desc[2]*2 <= desc[0] && desc[2]*2 <= desc[3]) || (desc[2]/2 >= desc[1] && desc[2]/2 >= desc[0] && desc[2]/2 >= desc[3])) { choices++; ch = 'C'; } if ((desc[3]*2 <= desc[1] && desc[3]*2 <= desc[2] && desc[3]*2 <= desc[0]) || (desc[3]/2 >= desc[1] && desc[3]/2 >= desc[2] && desc[3]/2 >= desc[0])) { choices++; ch = 'D'; } if (choices == 1) out.println(ch); else out.println("C"); //END } void runIO() { in = new Reader(); out = new PrintWriter(System.out, false); solve(); out.close(); } public static void main(String[] args) { new A().runIO(); } // input/output static class Reader { final private int BUFFER_SIZE = 1 << 16; private DataInputStream din; private byte[] buffer; private int bufferPointer, bytesRead; public Reader() { din = new DataInputStream(System.in); buffer = new byte[BUFFER_SIZE]; bufferPointer = bytesRead = 0; } public final String next() { int c = read(); while (isSpaceChar(c)) { c = read(); } StringBuilder res = new StringBuilder(); do { res.append((char) c); c = read(); } while (!isSpaceChar(c)); return res.toString(); } private boolean isSpaceChar(int c) { return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1; } public int nextInt() { int ret = 0; byte c = read(); while (c <= ' ') c = read(); boolean neg = (c == '-'); if (neg) c = read(); do { ret = ret * 10 + c - '0'; } while ((c = read()) >= '0' && c <= '9'); if (neg) return -ret; return ret; } public long nextLong() { long ret = 0; byte c = read(); while (c <= ' ') c = read(); boolean neg = (c == '-'); if (neg) c = read(); do { ret = ret * 10 + c - '0'; } while ((c = read()) >= '0' && c <= '9'); if (neg) return -ret; return ret; } public double nextDouble() { double ret = 0, div = 1; byte c = read(); while (c <= ' ') c = read(); boolean neg = (c == '-'); if (neg) c = read(); do { ret = ret * 10 + c - '0'; } while ((c = read()) >= '0' && c <= '9'); if (c == '.') while ((c = read()) >= '0' && c <= '9') ret += (c - '0') / (div *= 10); if (neg) return -ret; return ret; } public int[] readIntArray(int size) { int[] arr = new int[size]; for (int i = 0; i < size; i++) arr[i] = nextInt(); return arr; } public long[] readLongArray(int size) { long[] arr = new long[size]; for (int i = 0; i < size; i++) arr[i] = nextInt(); return arr; } private void fillBuffer() { try { bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE); } catch (IOException e) { } if (bytesRead == -1) buffer[0] = -1; } private byte read() { if (bufferPointer == bytesRead) fillBuffer(); return buffer[bufferPointer++]; } } }
JAVA
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
ls = [] count=0 ls.append( raw_input().strip()) ls.append( raw_input().strip()) ls.append( raw_input().strip()) ls.append( raw_input().strip()) ls[0] = ls[0][2:len(ls[0])] ls[1] = ls[1][2:len(ls[1])] ls[2] = ls[2][2:len(ls[2])] ls[3] = ls[3][2:len(ls[3])] char=-1 for i in xrange(4): flag=0 for j in xrange(4): if i==j: continue else: t = len(ls[i]) if t>=2*len(ls[j]): flag+=1 if flag==3: count+=1 char = i count1=0 char1=-1 for i in xrange(4): flag=0 for j in xrange(4): if i==j: continue else: t = len(ls[i]) if t<=len(ls[j])/2: flag+=1 if flag==3: count1+=1 char1 = i if count==1 and count1==0: if char==0: print 'A' elif char==1: print 'B' elif char==2: print 'C' elif char==3: print 'D' elif count==0 and count1==1: if char1==0: print 'A' elif char1==1: print 'B' elif char1==2: print 'C' elif char1==3: print 'D' else: print 'C'
PYTHON
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
import sys alpha = ["A", "B", "C", "D"] choices = [] for i in range(4): choices.append(len(sys.stdin.readline().strip()) - 2) lengths = list(choices) lengths.sort() if lengths[0] * 2 <= lengths[1] and lengths[3] >= lengths[2] * 2: print "C" elif lengths[0] * 2 <= lengths[1]: print alpha[choices.index(lengths[0])] elif lengths[3] >= lengths[2] * 2: print alpha[choices.index(lengths[3])] else: print "C"
PYTHON
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
a = raw_input()[2:] b = raw_input()[2:] c = raw_input()[2:] d = raw_input()[2:] lena = len(a) lenb = len(b) lenc = len(c) lend = len(d) lengthList = [len(a), len(b), len(c), len(d)] choice = 2 count = 0 for k in xrange(4): if (lengthList[k] >= 2 * lengthList[(k+1)%4]) and (lengthList[k] >= 2 * lengthList[(k+2)%4]) and (lengthList[k] >= 2 * lengthList[(k+3)%4]): choice = k count += 1 if (2 * lengthList[k] <= lengthList[(k+1)%4]) and (2 * lengthList[k] <= lengthList[(k+2)%4]) and (2 * lengthList[k] <= lengthList[(k+3)%4]): choice = k count += 1 if count == 1: if choice == 0: print 'A' elif choice == 1: print 'B' elif choice == 2: print 'C' elif choice == 3: print 'D' else: print 'C'
PYTHON
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
# python 3 """ """ from operator import itemgetter def the_child_and_homework(answers_list: list) -> str: answers_list.sort(key=itemgetter(1)) # print(answers_list) min_len = answers_list[0][1] choices = "" if min_len == answers_list[1][1]: pass else: if answers_list[1][1] >= 2 * min_len: choices += answers_list[0][0] else: pass max_len = answers_list[-1][1] if max_len == answers_list[-2][1]: pass else: if max_len >= 2 * answers_list[-2][1]: choices += answers_list[-1][0] else: pass if len(choices) == 1: return choices else: return "C" if __name__ == "__main__": """ Inside of this is the test. Outside is the API """ answers = [] for each in "ABCD": answer = input() answers.append((each, len(answer[2:]))) print(the_child_and_homework(answers))
PYTHON3
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
#include <bits/stdc++.h> using namespace std; int main() { int small = 1000, big = 0, k, x, y, z; char ch = 'C', chs, chl; bool bol1 = false, bol2 = false; string a, b, c, d; cin >> a >> b >> c >> d; k = a.size() - 2; x = b.size() - 2; y = c.size() - 2; z = d.size() - 2; if (k < x && k < y && k < z) { small = k; k = k * 2 + 2; chs = 'A'; } else if (x < k && x < y && x < z) { small = x; x = x * 2 + 2; chs = 'B'; } else if (y < x && y < k && y < z) { small = y; y = y * 2 + 2; chs = 'C'; } else if (z < x && z < y && z < k) { small = z; z = z * 2 + 2; chs = 'D'; } if (small * 2 <= k && small * 2 <= x && small * 2 <= y && small * 2 <= z) { bol1 = true; } k = a.size() - 2; x = b.size() - 2; y = c.size() - 2; z = d.size() - 2; if (k > x && k > y && k > z) { big = k; k = 0; chl = 'A'; } else if (x > k && x > y && x > z) { big = x; x = 0; chl = 'B'; } else if (y > x && y > k && y > z) { big = y; y = 0; chl = 'C'; } else if (z > x && z > y && z > k) { big = z; z = 0; chl = 'D'; } big /= 2; if ((big >= k) && (big >= x) && (big >= y) && (big >= z)) { bol2 = true; } if ((bol1 == true && bol2 == true) || (bol1 == false && bol2 == false)) { ch = 'C'; cout << ch; } else if (bol1) cout << chs; else cout << chl << endl; }
CPP
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b) { return (b != 0 ? gcd(b, a % b) : a); } int lcm(int a, int b) { return (a / gcd(a, b) * b); } int main(int argc, const char **argv) { string a[4]; int l[4], lm[4], i, x, c, d; for (int i = 0; i < 4; i++) { cin >> a[i]; l[i] = a[i].length() - 2; } for (int i = 0; i < 4; i++) { lm[i] = l[i]; } sort(lm, lm + 4); c = 0; d = 0; for (int i = 1; i < 4; i++) { x = lm[i] - lm[0]; if (x >= lm[0]) { c++; } } x = lm[3] / 2; for (int i = 0; i < 3; i++) { if (x >= lm[i]) { d++; } } if (c == 3 && d < 3) { for (int i = 0; i < 4; i++) { if (lm[0] == l[i]) { cout << a[i][0] << endl; } } } else if (d == 3 && c < 3) { for (int i = 0; i < 4; i++) { if (lm[3] == l[i]) { cout << a[i][0] << endl; } } } else cout << 'C' << endl; return 0; }
CPP
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
#include <bits/stdc++.h> using namespace std; int main() { string s[4]; pair<int, int> max, min; int l[4]; for (__typeof(4) i = 0; i < 4; i++) { cin >> s[i]; l[i] = s[i].length() - 2; } for (__typeof(4) i = 0; i < 4; i++) { if (i == 0) { max.first = min.first = 0; max.second = min.second = l[i]; } if (l[i] > max.second) { max.first = i; max.second = l[i]; } if (l[i] < min.second) { min.first = i; min.second = l[i]; } } int flagMax = 0; int flagMin = 0; for (__typeof(4) i = 0; i < 4; i++) { if (i != max.first && l[i] * 2 <= max.second) { flagMax++; } if (i != min.first && l[i] >= min.second * 2) { flagMin++; } } if (flagMax == 3) { if (flagMin == 3) cout << "C"; else cout << (char)('A' + max.first); } else if (flagMin == 3) cout << (char)('A' + min.first); else cout << "C"; }
CPP
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
#include <bits/stdc++.h> using namespace std; int main() { string a, b, c, d; getline(cin, a); getline(cin, b); getline(cin, c); getline(cin, d); int a1 = a.length() - 2; int b1 = b.length() - 2; int c1 = c.length() - 2; int d1 = d.length() - 2; int great = 0; int great1 = 0; if (a1 >= b1 * 2 && a1 >= c1 * 2 && a1 >= d1 * 2 || a1 <= b1 / 2 && a1 <= c1 / 2 && a1 <= d1 / 2) { great++; great1 = 1; } if (b1 >= a1 * 2 && b1 >= c1 * 2 && b1 >= d1 * 2 || b1 <= a1 / 2 && b1 <= c1 / 2 && b1 <= d1 / 2) { great++; great1 = 2; } if (c1 >= a1 * 2 && c1 >= b1 * 2 && c1 >= d1 * 2 || c1 <= a1 / 2 && c1 <= b1 / 2 && c1 <= d1 / 2) { great++; great1 = 3; } if (d1 >= a1 * 2 && d1 >= b1 * 2 && d1 >= c1 * 2 || d1 <= a1 / 2 && d1 <= b1 / 2 && d1 <= c1 / 2) { great++; great1 = 4; } if (great == 1) cout << (char)('A' + great1 - 1); else cout << "C"; }
CPP
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
#!/usr/bin/env pypy """ Created on Mon Dec 14 13:18:46 2020 @author: yash """ """ _ _ ____ _ ____ | | __ _(_) / ___|| |__ _ __ ___ ___ | _ \ __ _ _ __ ___ _ | |/ _` | | \___ \| '_ \| '__/ _ \/ _ \ | |_) / _` | '_ ` _ \ | |_| | (_| | | ___) | | | | | | __/ __/ | _ < (_| | | | | | | \___/ \__,_|_| |____/|_| |_|_| \___|\___| |_| \_\__,_|_| |_| |_| """ """ """ """ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░████████░░░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█████████░░░░░░░░░░░░░░░░░▌░░░ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░◐◐◐█████████▀▀▀▀▀▀🔥░░░░░░░░███ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█████████░░░░░░░░░░░░░░░░░░░░▌░░░ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█████████░░░░░░░░░░░░░░░░░░░░█▌░░░ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▄▄▀█████████████████████████████████████████████████ ░░░░░░░░░░░░░░░░░░░░░░░░░░▄▄▄████▄████████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ████ ░░░░░░░░░░░░░░░░░░░░░░░░░░░▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀█████████▀▀▀▀▀▀▀▀▀ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█████████░░░░░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░◐◐◐█████████▀▀▀▀▀▀🔥░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█████████░░░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█████████░░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░████████░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░███████░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░██████░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█████░░░░░░░░░░░░░░░ """ """ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#@#@@#@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@##@M@M # #@@@M@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#@@@@#@@ @@@@@@M@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#@@### #@@B@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#@@B@@#@@@@@#M@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#@##@@M@#@@##@##@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#@@#M@@@@@##@M@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@##@@@@@@#@##@#@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#@@# @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@M@@ # @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#@@#@@#@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @# @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @# @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#@@#@@#@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@M@@ # @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#@@# @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ @@#@@#@@@@@@@@@@@@@@@@@#@@#@#@@@@@@@@@@@@@@@@@@@@@#@#@@@@@@@@@@@@@@@@@@@@@@@@@ @ #@@@@@@@@@@@@@@@@@@@@#@@@@@@#@@@@@@@@@@@@@@@@@#@#@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ @@#@#@@@@@@@@@@@@@@@@@@#@####@@@@@@@@@@@@@@@@@M@#@@#@#@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@#@#M@@@M@@@@@@@@@@@@@@@@@@@M@@@@@@@@@@@@@@@@@@@@@@@@@@@@ #@M@#@#@@@@@@@@@@@@@@@@@@#@@@@@@@@@@@@@@@@@@@@@@@@M@@M@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@#@@#@@@@@@@@@@@@@@@@@@@@M@M@#@@@@@@@@@@@@@@@@@@@@@@@#@@@@@@@@@@@@@@@@@@@@@@@@ @@#@@#@@@@@@@@@@@@@@@@@@@@@@@M@ @M@@#@@@@@@@@@@@@@@@@@@@@@@@@@ @#@@@@@#@@@@@@@@@@@@@@@@@@@#@@ @@@@M@@@@@@@@@@@@@@@@@@@@@@@@ @@@#@@@##@@@#@@@@@#@@@@@##@@@@ #@#@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@####@@####@@@@#@@@@M@@@#@@# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @#@ @#@@#@@@ #@ @ #@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @# @@#@@ #@@#@@@@@@@@@@@@@@@@@@@@@@@@@ ##@#@@ #M @# @@ @@M @@@@@@@@@@@@@@@@@@@@@@@@ @#@@@M #@ #@ # @@ @@@@@@@@@@@@@@@@@@@@@@@@ @@ @@#@@ ## @##@@ @@@@@@@@@@@@@@@@@@@@@@@@ @# @@M@ @@ @@@@@@@@@@@@@@@@@@@@@@@@ @@@##@@@ @@@@ @@@ @@ #@#@@#@@@@@@@@@@@@@@@@@ @@@@###@@###@@@@#@#@@@@#@@@ M@ #@ @ B @@@#@@@@@@@@@@@@@@@@@@@ @M@@@@@MM@@@@@M@@#@##@@@#@@M@B @# M@ @# #@ #@@#@@@@@@@@@@@@@@@@@@@ @#@#@@M@@M@@#@#@#@#@@#@#@#@@@@ @# @@ # @M @#@@@@@@@@@@@@@@@@@@@@@ @@@ @@@@#@##@ #@# @M # @ @ @@@@@#@@@@@@@@@@@@@@@@@ @@ @@ @#@@#@@#M #@@@@#@@@@@@@@@@@@@@@@@ M@# #@ @@@@##@@ @M@#M@@@#@@@@@@@@@@@@@@@@ @@@@ @@ @@@#@@@#@#@@@@@@@@@@@@@@@@ @# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @M@H@@ @# @#@@@@#@@@#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@#@#@##@M@@@M@ @M#@@@@@#@@#@@#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ #M@@@##@@@@@@@@M@@@@#@@#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@#@@@@@M@#@M@@B#M@@M@###@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ###@@@@@@@@@# @#@@@@@@@#@@@#@##@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@#@@M@@@#@@#@#@@@@@@#@@@#@#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#@M@#@# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@M@@@@# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#@@@@@#@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@M@@## @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#@@#@M @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@###@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#@@@@@#@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@# #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@# #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ """ """ / \ //\ |\___/| / \// \\ /0 0 \__ / // | \ \ / / \/_/ // | \ \ @_^_@'/ \/_ // | \ \ //_^_/ \/_ // | \ \ ( //) | \/// | \ \ ( / /) _|_ / ) // | \ _\ ( // /) '/,_ _ _/ ( ; -. | _ _\.-~ .-~~~^-. (( / / )) ,-{ _ `-.|.-~-. .~ `. (( // / )) '/\ / ~-. _ .-~ .-~^-. \ (( /// )) `. { } / \ \ (( / )) .----~-.\ \-' .~ \ `. \^-. ///.----..> \ _ -~ `. ^-` ^-_ ///-._ _ _ _ _ _ _}^ - - - - ~ ~-- ,.-~ /.-~ """ """ ____ _ _____ / ___|___ __| | ___| ___|__ _ __ ___ ___ ___ | | / _ \ / _` |/ _ \ |_ / _ \| '__/ __/ _ \/ __| | |__| (_) | (_| | __/ _| (_) | | | (_| __/\__ \ \____\___/ \__,_|\___|_| \___/|_| \___\___||___/ """ """ ░░██▄░░░░░░░░░░░▄██ ░▄▀░█▄░░░░░░░░▄█░░█░ ░█░▄░█▄░░░░░░▄█░▄░█░ ░█░██████████████▄█░ ░█████▀▀████▀▀█████░ ▄█▀█▀░░░████░░░▀▀███ ██░░▀████▀▀████▀░░██ ██░░░░█▀░░░░▀█░░░░██ ███▄░░░░░░░░░░░░▄███ ░▀███▄░░████░░▄███▀░ ░░░▀██▄░▀██▀░▄██▀░░░ ░░░░░░▀██████▀░░░░░░ ░░░░░░░░░░░░░░░░░░░░ """ """░░██▄░░░░░░░░░░░▄██ ░▄▀░█▄░░░░░░░░▄█░░█░ ░█░▄░█▄░░░░░░▄█░▄░█░ ░█░██████████████▄█░ ░█████▀▀████▀▀█████░ ▄█▀█▀░░░████░░░▀▀███ ██░░▀████▀▀████▀░░██ ██░░░░█▀░░░░▀█░░░░██ ███▄░░░░░░░░░░░░▄███ ░▀███▄░░████░░▄███▀░ ░░░▀██▄░▀██▀░▄██▀░░░ ░░░░░░▀██████▀░░░░░░ ░░░░░░░░░░░░░░░░░░░░ """ """ # Codeforces Round #186 (Div. 2), problem: (A) Ilya and Bank Account n = int(input()) if n > 0: print(n) else: s = str(n) if s[len(s)-1] < s[len(s)-2] and s[len(s)-2] != '0': print(int(s[:len(s)-2] + s[len(s)-1:])) elif s[len(s)-1] > s[len(s)-2] and s[len(s)-1] != '0': print(int(s[:len(s)-1])) else: print(int(s[:len(s)-1])) """ """ # Codeforces Round #261 (Div. 2), problem: (A) Pashmak and Garden, x1, y1, x2, y2=map(int,input().split()) l=abs(x1-x2) m=abs(y1-y2) if x1==x2: print(x1+m,y1,x2+m,y2) elif y1==y2: print(x1,y1+l,x2,y2+l) elif l!=m: print(-1) else: print(x1,y2,x2,y1) """ """ # Codeforces Round #142 (Div. 2), problem: (A) Dragons def solve(): s, n = map(int, input().split()) sets = [] for _ in range(n): ith, bonus = map(int, input().split()) sets.append([ith, bonus]) sets.sort(key=lambda x: x[0]) for i in sets: if i[0] < s: s += i[1] else: return "NO" return "YES" print(solve()) """ """ # Codeforces Round #690 (Div. 3) # (A) Favorite Sequence- for _ in range(int(input())): n = int(input()) l = list(map(int, input().split())) ans = [] k = n//2 start = 0 end = len(l)-1 while start <= end: if start != end: ans.append(l[start]) ans.append(l[end]) else: ans.append(l[end]) start += 1 end -= 1 for i in ans: print(i, end=" ") print() # B) Last Year's Substring- for _ in range(int(input())): n = int(input()) s = input() if s[0]+s[1] == '20' and s[-2]+s[-1] == '20': print("YES") elif s[0] == '2' and s[-3]+s[-2]+s[-1] == '020': print("YES") elif s[0]+s[1]+s[2] == '202' and s[-1] == '0': print("YES") elif s[0]+s[1]+s[2]+s[3] == '2020': print("YES") elif s[-4]+s[-3]+s[-2]+s[-1] == '2020': print("YES") else: print("NO") """ """ # Codeforces Round #251 (Div. 2) n, d = map(int, input().split()) l = list(map(int, input().split())) if (sum(l) + (n-1)*10) > d: print(-1) else: print((d-sum(l))//5) """ """ # Codeforces Round #290 (Div. 2) n,m=map(int,input().split()) for i in range(n): if i % 4 == 0: print('#'*m) elif i % 4 == 1: print('.'*(m-1)+'#') elif i % 4 == 2: print('#'*m) else: print('#'+'.'*(m-1)) n,m=map(int,input().split()) for i in range(n): print(['#'*m,'.'*(m-1)+'#','#'*m,'#'+'.'*(m-1)][i%4]) """ """ # Educational Codeforces Round 100 (Rated for Div. 2) # problem: (A) Dungeon def solve(a, b, c): s = a+b+c k = s//9 if s % 9 == 0 and a >= k and b >=k and c >= k: return "YES" else: return "NO" for _ in range(int(input())): a, b, c = map(int, input().split()) print(solve(a, b, c)) # problem: (B) Find The Array for _ in range(int(input())): n = int(input()) l = list(map(int, input().split())) even = 0 odd = 0 for i in range(len(l)): if i % 2 == 0: even += l[i] else: odd += l[i] if even < odd: for i in range(len(l)): if i % 2 == 0: l[i] = 1 print(l[i], end=" ") else: print(l[i], end=" ") else: for i in range(len(l)): if i % 2 == 0: print(l[i], end=" ") else: l[i] = 1 print(l[i], end=" ") """ """ # Codeforces Beta Round #25 (Div. 2 Only), problem: (A) IQ test n = int(input()) nums = list(map(int, input().split())) even = 0 odd = 0 counter1 = 0 counter2 = 0 for i in range(len(nums)): if nums[i]%2 == 0: counter1+=1 even = i+1 else: counter2+=1 odd = i+1 if counter1 == 1: print(even) else: print(odd) """ """ # Codeforces Round #246 (Div. 2), problem: (A) Choosing Teams n, k = map(int, input().split()) l = list(map(int, input().split())) counter = 0 for i in range(len(l)): if (5-l[i]) >= k: counter += 1 print(counter//3) """ """ # Codeforces Round #192 (Div. 2), problem: (A) r, c = map(int, input().split()) a = set() b = set() for i in range(r): d = input() for j in range(len(d)): if d[j] == 'S': a.add(j) b.add(i) print(r*c - len(a)*len(b)) """ # n, m = map(int, input().split()) # b = [] # for i in range(n): # if min(list(map(int, input().split()))[1:]) < m: # b.append(i + 1) # print(len(b), '\n', *b) """ # Codeforces Round #691 (Div. 2), problem: (A) Red-Blue Shuffle, for i in range(int(input())): n = int(input()) a = input() b = input() counter_a = 0 counter_b = 0 for j in range(len(a)): if a[j] > b[j]: counter_a += 1 elif a[j] < b[j]: counter_b += 1 if counter_a > counter_b: print("RED") elif counter_a < counter_b: print("BLUE") else: print("EQUAL") """ """ # Codeforces Round #263 (Div. 2), problem: (A) Appleman and Easy Task x = '' for _ in range(int(input())): x += input() if x == x[::-1]: print("YES") else: print("NO") """ """ # Codeforces Round #226 (Div. 2), problem: (A) Bear and Raspberry n, c = map(int, input().split()) l = list(map(int, input().split())) ans = l[0] - l[1] for i in range(1, len(l)-1): ans = max(ans, l[i] - l[i+1]) if ans - c < 0: print(0) else: print(ans-c) """ # n, k = map(int, input().split()) # joy = float("-inf") # for _ in range(n): # f, t = map(int, input().split()) # if t >= k: # joy = max(joy, f - (t - k)) # else: # joy = max(joy, f) # print(joy) """ # Codeforces Round #260 (Div. 2), problem: (A) Laptops, for _ in range(int(input())): a,b=input().split() if a!=b: print('Happy Alex') exit() print('Poor Alex') """ """ # Technocup 2021 - Elimination Round 3: problem: (A) In-game Chat for _ in range(int(input())): n = int(input()) s = input() j = len(s)-1 count = 0 while j >= 0: if s[j] != ')': break count += 1 j -= 1 if count > len(s)-count: print("YES") else: print("NO") """ # def solve(x): # for i in str(x): # if i != '0' and x % int(i) != 0: # return False # return True # t = int(input()) # for _ in range(t): # n = int(input()) # while not solve(n): # n += 1 # print(n) """ # Codeforces Round #222 (Div. 2), problem: (A) Playing with Dice a, b = map(int, input().split()) a_w = 0 b_w = 0 draw = 0 for i in range(1, 7): if abs(i-a) < abs(i-b): a_w += 1 elif abs(i-a) > abs(i-b): b_w += 1 else: draw += 1 print(a_w, draw, b_w) """ """ # Codeforces Round #283 (Div. 2), problem: (A) Minimum Difficulty n=int(input()) l=list(map(int,input().split())) x=max([l[i+1]-l[i] for i in range(n-1)]) y=min([l[i+2]-l[i] for i in range(n-2)]) print(max(x,y)) """ """ # Codeforces Round #156 (Div. 2), problem: (A) Greg's Workout n = int(input()) arr = list(map(int, input().split())) chest_count = 0 biceps_count = 0 back_count = 0 for i in range(len(arr)): if i%3 == 0: chest_count += arr[i] elif i%3 == 1: biceps_count += arr[i] elif i%3 == 2: back_count += arr[i] ans = max(chest_count, biceps_count, back_count) if chest_count == ans: print("chest") elif biceps_count == ans: print("biceps") else: print("back") OR input() arr = [int(i) for i in input().split()] b = [sum(arr[::3]), sum(arr[1::3]), sum(arr[2::3])] c = ['chest', 'biceps', 'back'] print(c[b.index(max(b))]) """ """ # Codeforces Round #275 (Div. 2), problem: (A) Counterexample l, r = map(int, input().split()) if r - l + 1 < 3: print(-1) exit() if l % 2 == 0: print(l, l+1, l+2) exit() if r - l + 1 > 3: print(l+1, l+2, l+3) exit() print(-1) """ """ # Codeforces Round #237 (Div. 2), problem: (A) Valera and X s = '' n = int(input()) for i in range(n): s += input() if s == s[::-1] and s.count(s[0]) == (2*n-1): print("YES") else: print("NO") OR n = int(input()) x, y = set(), set() for i in range(n): line = input() for j in range(n): if i == j or i == n - j - 1: x.add(line[j]) else: y.add(line[j]) if len(x) == 1 and len(y) == 1and x != y: print("YES") else: print("NO") """ """ # Codeforces Round #144 (Div. 2), problem: (A) Perfect Permutation n = int(input()) startIdx = 1 secondIdx = 2 l = [int(i) for i in range(n, 0, -1)] if n%2 == 0: while secondIdx <= n: l.append(secondIdx) l.append(startIdx) startIdx += 2 secondIdx += 2 else: print(-1) OR n=int(input()) if n%2: print(-1) else: print(*range(n,0,-1)) """ """ # Codeforces Round #284 (Div. 2), problem: (A) Watching a movie n, x = map(int, input().split()) minute = 1 for _ in range(n): l, r = map(int, input().split()) difference = l - minute minute = minute + difference%x minute = minute + (r-l+1) print(minute-1) """ """ # Codeforces Round #112 (Div. 2), problem: (A) Supercentral Point, n = int(input()) l = [] for _ in range(n): x, y = map(int, input().split()) l.append([x, y]) ans = 0 for i in range(n): left=right=upper=down = 0 for j in range(n): if l[i][0] > l[j][0] and l[i][1] == l[j][1]: right += 1 if l[i][0] < l[j][0] and l[i][1] == l[j][1]: left += 1 if l[i][0] == l[j][0] and l[i][1] > l[j][1]: upper+= 1 if l[i][0] == l[j][0] and l[i][1] < l[j][1]: down += 1 if (right and left and upper and down): ans += 1 print(ans) OR n = int(input()) l = [] for _ in range(n): x, y = map(int, input().split()) l.append([x, y]) ans = 0 for i in range(n): left=right=upper=down = 0 for j in range(n): if l[i][0] > l[j][0] and l[i][1] == l[j][1]: right = 1 elif l[i][0] < l[j][0] and l[i][1] == l[j][1]: left = 1 elif l[i][0] == l[j][0] and l[i][1] > l[j][1]: upper= 1 elif l[i][0] == l[j][0] and l[i][1] < l[j][1]: down = 1 if right==left==upper==down==1: ans += 1 print(ans) """ """ # Codeforces Round #160 (Div. 2), problem: (A) Roma and Lucky Numbers n, k = map(int, input().split()) arr = list(map(int, input().split())) count = 0 for i in arr: if ((str(i).count('4'))+(str(i).count('7')) <= k): count += 1 print(count) """ """ # A. Contest - Codeforces Round #285 (Div. 2) a, b, t1, t2 = map(int, input().split()) mishra = max((3*a)/10, a - (a/250) * t1) vasya = max((3*b)/10, b - (b/250) * t2) if int(mishra) > int(vasya): print("Misha") elif int(mishra) < int(vasya): print("Vasya") else: print("Tie") """ """ # Codeforces Round #203 (Div. 2), problem: (A) n, m = map(int, input().split()) a = list(map(int, input().split()[:n])) b = list(map(int, input().split()[:m])) v = min(a)*2 p = min(b) c = max(a) if v < p and c < p: print(max(v, c)) else: print(-1) """ """ # Codeforces Round #205 (Div. 2), problem: (A) Domino a = 0 b = 0 check = 0 for _ in range(int(input())): p, q = map(int, input().split()) a += p b += q if (a % 2 == 1 and b % 2 == 0) or (a % 2 == 0 and b % 2 == 1): check += 1 if a % 2 == b % 2 == 0: print(0) elif a % 2 == b % 2 == 1 and check > 0: print(1) else: print(-1) """ """ # Codeforces Beta Round #86 (Div. 2 Only), problem: (A) Cifera k = int(input()) l = int(input()) i = 0 while k**i < l: i += 1 if l == k**i: print("YES") print(i-1) else: print("NO") """ """ # Codeforces Round #181 (Div. 2), problem: (A) Array, n = int(input()) count_negative = 0 l = list(map(int, input().split())) set_A = [] set_B = [] set_C = [] for i in range(n): if l[i] < 0: set_A.append(l[i]) elif l[i] > 0: set_B.append(l[i]) else: set_C.append(l[i]) if len(set_B) == 0: for i in range(2): set_B.append(set_A.pop()) if len(set_A) % 2 == 0: set_C.append(set_A.pop()) print(len(set_A), *set_A) print(len(set_B), *set_B) print(len(set_C), *set_C) """ """ n = int(input()) l = sorted(map(int, input().split())) while len(set(l)) != 1: l[-1] -= l[0] l.sort() print(sum(l)) """ """ # Codeforces Round #278 (Div. 2), problem: (A) Giga Tower def solve(x): for i in str(x): if i == '8': return True return False t = int(input()) t += 1 s = str(t) count = 1 while not solve(t): count += 1 t += 1 print(count) OR n = int(input()) b = 1 while not '8' in str(n+b): b += 1 print(b) """ # n, m = map(int, input().split()) # a = ['W', 'B'] # for i in range(n): # s = list(input()) # for j in range(m): # if s[j] == '.': # s[j] = a[(i+j)%2] # print(''.join(s)) """ # Codeforces Beta Round #42 (Div. 2), problem: (A) Football n = int(input()) freq = {} for i in range(n): s = input() if s not in freq: freq[s] = 0 freq[s] += 1 ans = max(freq.values()) for i in freq.keys(): if freq[i] == ans: print(i) OR n = int(input()) l = [] for i in range(n): l.append(input()) print(max(set(l), key=l.count)) """ """ # Codeforces Beta Round #67 (Div. 2), problem: (A) Life Without Zeros a = int(input()) b = int(input()) c = a + b if int(str(a).replace('0', '')) + int(str(b).replace('0', '')) == int(str(c).replace('0', '')): print("YES") else: print("NO") """ # def solve(): # n = int(input()) # l = list(map(int, input().split()[:n])) # for i in range(len(l)-1): # if l[i] == l[i+1]: # j = i+1 # while j < len(l)-1: # if l[i+1] != l[j+1]: # l[i+1], l[j+1] = l[j+1], l[i+1] # break # j += 1 # for i in range(len(l)-1): # if l[i] == l[i+1]: # j = i+1 # while j < len(l)-1: # if l[i+1] != l[j+1]: # l[i+1], l[j+1] = l[j+1], l[i+1] # break # j += 1 # for i in range(len(l)-1): # if l[i] == l[i+1]: # return "NO" # return "YES" # print(solve()) """ # Codeforces Round #179 (Div. 2), problem: (A) Yaroslav and Permutations, import math def solve(): n = int(input()) l = list(map(int, input().split()[:n])) freq = {} for i in l: if i not in freq: freq[i] = 0 freq[i] += 1 for i in freq.values(): if i > math.ceil(n/2): return "NO" return "YES" print(solve()) """ """ n, k = map(int, input().split()) for i in range(n): for j in range(n): if i == j: print(k, end = " ") else: print(0, end = " ") print() """ """ # Codeforces Round #206 (Div. 2), problem: (A) Vasya and Digital Root, k, d = input().split() k = int(k)-1 if (d == '0')*k: print('No solution') else: print(d+'0'*k) """ """ y, k, n = map(int, input().split()) s = n - y x = k - y % k a = 0 while x <= s: print(x, end = ' ') x = x + k a = 1 if a == 0: print(-1) """ a = input() b = input() c = input() d = input() dic = {'A':len(a[2:]), 'B': len(b[2:]), 'C':len(c[2:]), 'D': len(d[2:])} max_count = 0 min_count = 0 max_len = max(dic.values()) min_len = min(dic.values()) for i in dic.values(): if max_len >= i*2 and i != max_len: max_count += 1 for i in dic.values(): if min_len*2 <= i and i != min_len: min_count += 1 # print(max_count) # print(min_count) if max_count == min_count: print("C") elif max_count == 3: for i in dic: if dic[i] == max_len: print(i) elif min_count == 3: for i in dic: if dic[i] == min_len: print(i) else: print("C") # s = input() # t = input() # count = 0 # i = 0 # while i < len(t): # if t[i] == s[count]: # count += 1 # i +=1 # print(count+1) # def Sorted(l, key=None): # new_list = list(l) # new_list.sort(key=key) # return new_list # l = [2,1,3,10,3] # print(Sorted(l)) # print(l) #Problem - A # for i in range(int(input())): # arr = list(map(int, input().split())) # arr.sort() # print(arr[0]*arr[2]) #problem - N # for i in range(int(input())): # c1, c2, c3 = map(int, input().split()) # a1, a2, a3, a4, a5 = map(int, input().split()) # if c1 >= a1 and c2 >= a2 and c3 >= a3 and c1+c3 >= a1+a3+a4 and c2+c3 >= a2+a3+a5 and (c1+c2+c3) >= (a1+a2+a3+a4+a5): # print("YES") # else: # print("NO")
PYTHON3
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
s = [[] for i in range(4)] for i in range(4): s[i] = raw_input() l = [] pos = f = 0 for i in range(4): l.append(len(s[i])-2) for i in range(4): c1 = c2 = 0 for j in range(4): if j != i and l[j] >= l[i]*2: c1 += 1 if j != i and l[j]*2 <= l[i]: c2 += 1 if c1 == 3 or c2 == 3: f += 1 pos = i if f == 1: print chr(65+pos) else: print 'C'
PYTHON
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
def get_len(x) : return len(x) a=list(input() for i in range(4)) a.sort(key=get_len) s=(2*len(a[0])<=len(a[1])+2) l=(2*len(a[2])<=len(a[3])+2) print("C" if s^l==0 else (a[0][0] if s else a[3][0]))
PYTHON3
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
a=(raw_input()) b=(raw_input()) c=(raw_input()) d=(raw_input()) p=[len(a)-2,len(b)-2,len(c)-2,len(d)-2] q=['A','B','C','D'] maxi=max(p) mini=min(p) ans=2 k=0 for i in xrange(4): big=True small=True for j in xrange(4): if i!=j: if p[i]<(2*p[j]): big=False if p[i]>(p[j]/2): small=False if big or small: ans=i k+=1 if k==1: print q[ans] else: print 'C'
PYTHON
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
#include <bits/stdc++.h> int main() { char a[200]; char b[200]; char c[200]; char d[200]; char x; int i; int len[4]; scanf("%c", &x); scanf("%c", &x); scanf("%s\n", a); scanf("%c", &x); scanf("%c", &x); scanf("%s\n", b); scanf("%c", &x); scanf("%c", &x); scanf("%s\n", c); scanf("%c", &x); scanf("%c", &x); scanf("%s", d); len[0] = strlen(a); len[1] = strlen(b); len[2] = strlen(c); len[3] = strlen(d); int min = 101; int max = -1; int mini; int maxi; for (i = 0; i < 4; i++) { if (len[i] > max) { max = len[i]; maxi = i; } if (len[i] < min) { min = len[i]; mini = i; } } char ch[] = {'Z', 'Z'}; int flag1 = 1; int flag2 = 1; for (i = 0; i < 4; i++) { if (i != mini) { if (min > (len[i] / 2)) { flag1 = 0; break; } } } if (flag1) { if (mini == 0) { ch[0] = 'A'; } else if (mini == 1) { ch[0] = 'B'; } else if (mini == 2) { ch[0] = 'C'; } else { ch[0] = 'D'; } } flag2 = 1; for (i = 0; i < 4; i++) { if (i != maxi) if (max < (2 * len[i])) { flag2 = 0; break; } } if (flag2) { if (maxi == 0) { ch[1] = 'A'; } else if (maxi == 1) { ch[1] = 'B'; } else if (maxi == 2) { ch[1] = 'C'; } else { ch[1] = 'D'; } } if ((flag1 == 0 && flag2 == 0) || (flag1 == 1 && flag2 == 1)) { printf("C"); } else { if (flag1 == 1) { printf("%c", ch[0]); } else { printf("%c", ch[1]); } } return 0; }
CPP
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
#include <bits/stdc++.h> using namespace std; string a, b, c, d; pair<int, char> arr[10]; bool cek1, cek2; int main() { cin >> a; cin >> b; cin >> c; cin >> d; arr[0] = make_pair(a.length() - 2, 'A'); arr[1] = make_pair(b.length() - 2, 'B'); arr[2] = make_pair(c.length() - 2, 'C'); arr[3] = make_pair(d.length() - 2, 'D'); sort(arr, arr + 4); cek1 = cek2 = false; if (arr[0].first * 2 <= arr[1].first) cek1 = true; if (arr[3].first >= 2 * arr[2].first) cek2 = true; if (cek1 && !cek2) cout << arr[0].second << endl; else if (!cek1 && cek2) cout << arr[3].second << endl; else cout << "C" << endl; }
CPP
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int[] l = new int[4]; for(int i=0;i<4;i++) { l[i] = sc.next().length()-2; } int goodindex = -1; for(int i=0;i<4;i++) { boolean longer = true; boolean shorter = true; for(int j=0;j<4;j++) { if (i == j) { continue; } if (l[i] < l[j] * 2) { longer = false; } if (l[i] * 2 > l[j]) { shorter = false; } } if (longer || shorter) { if (goodindex == -1) { goodindex = i; }else{ goodindex = -1; break; } } } if (goodindex == -1) { System.out.println("C"); }else{ char c = (char) ('A' + goodindex); System.out.println(c); } } }
JAVA
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
#include <bits/stdc++.h> int l[4]; bool judge1(int x); bool judge2(int x); int main(void) { char str[105]; for (int i = 0; i < 4; i++) { scanf("%s", str); l[str[0] - 'A'] = strlen(str + 2); } int flag = 0, ans = 0; for (int i = 0; i < 4; i++) { if (judge1(i) || judge2(i)) { flag++; ans = i; } } if (flag == 1) printf("%c\n", ans + 'A'); else printf("C\n"); return 0; } bool judge1(int x) { for (int i = 0; i < 4; i++) { if (i == x) continue; if (l[i] * 2 > l[x]) return false; } return true; } bool judge2(int x) { for (int i = 0; i < 4; i++) { if (i == x) continue; if (l[i] < l[x] * 2) return false; } return true; }
CPP
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
#include <bits/stdc++.h> using namespace std; int main() { vector<pair<int, char> > nb(4); for (auto &i : nb) { string a; cin >> a; i.first = a.size() - 2; i.second = a[0]; } sort(nb.begin(), nb.end()); int ax(0); int ax1(0); for (int i = 1; i < 4; ++i) { if (nb[0].first * 2 <= nb[i].first) ++ax; } for (int i = 2; i >= 0; --i) { if (nb[3].first >= nb[i].first * 2) ++ax1; } if (ax == ax1 || ax < 3 && ax1 < 3) { cout << 'C'; return 0; } if (ax == 3) { cout << nb[0].second; return 0; } cout << nb[3].second; }
CPP
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
import java.io.InputStreamReader; import java.io.IOException; import java.io.FileReader; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.io.Writer; import java.util.StringTokenizer; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * @author Agostinho Junior (junior94) */ public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); OutputWriter out = new OutputWriter(outputStream); TaskA solver = new TaskA(); solver.solve(1, in, out); out.close(); } } class TaskA { OutputWriter out; InputReader in; public void solve(int testNumber, InputReader in, OutputWriter out) { this.in = in; this.out = out; int[] longer = new int[4]; int[] shorter = new int[4]; int[] len = new int[4]; for (int i = 0; i < 4; i++) { len[i] = in.readLine().length() - 2; } for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { if (i != j) { if (len[j] * 2 <= len[i]) { longer[i]++; } else if (len[j] >= len[i] * 2) { shorter[i]++; } } } } char ans = '.'; for (int i = 0; i < 4; i++) { if (longer[i] == 3 || shorter[i] == 3) { if (ans == '.') { ans = (char)('A' + i); } else { ans = 'x'; } } } if (ans == 'x' || ans == '.') { ans = 'C'; } out.print(ans); } } class OutputWriter { private PrintWriter output; public OutputWriter() { this(System.out); } public OutputWriter(OutputStream out) { output = new PrintWriter(out); } public OutputWriter(Writer writer) { output = new PrintWriter(writer); } public void print(Object o) { output.print(o); } public void close() { output.close(); } } class InputReader { private BufferedReader input; public InputReader() { this(System.in); } public InputReader(InputStream in) { input = new BufferedReader(new InputStreamReader(in)); } public InputReader(String s) { try { input = new BufferedReader(new FileReader(s)); } catch(IOException io) { io.printStackTrace(); System.exit(0);} } public String readLine() { String s = ""; try { s = input.readLine(); } catch(IOException io) {io.printStackTrace(); System.exit(0);} return s; } }
JAVA
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
#include <bits/stdc++.h> using namespace std; int main() { int ar[4]; string s; for (int i = 0; i < (4); i++) { cin >> s; ar[i] = s.length() - 2; } string res = "ABCD"; char small = 'n', large = 'n'; int cnt = 0, len; for (int i = 0; i < 4; i++) { cnt = 0; len = ar[i]; for (int j = 0; j < 4; j++) { if (i == j) continue; if (2 * ar[j] <= len) cnt++; if (2 * len <= ar[j]) cnt--; } if (cnt == 3) { large = (char)res[i]; } if (cnt == -3) { small = (char)res[i]; } } if (small == 'n' && large != 'n') cout << large << endl; else if (large == 'n' && small != 'n') cout << small << endl; else cout << "C" << endl; return 0; }
CPP
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
import java.util.* ; import java.lang.* ; import java.io.*; public class javaTemplate { static FastReader sc = new FastReader(); // static Scanner sc = new Scanner(System.in) ; public static void main(String[] args) { String s[] = new String[4] ; int length[] = new int[4] ; for(int i = 0 ; i< 4 ; i++) { s[i] = sc.next() ; length[i] = s[i].length()-2 ; } ArrayList<Character> llist = new ArrayList<>() ; for(int i = 0 ; i< 4 ; i++) { boolean isShort = true ; boolean isLong = true ; int length2 = length[i] ; for(int j = 0 ; j< 4 ; j++) { if(j != i) { if(!(2*length2 <= length[j])) { isShort = false ; } if(!(length2 >= 2*length[j])) { isLong = false ; } } } if(isShort || isLong) { char ch = (char) ('A'+i) ; llist.add(ch) ; } } if(llist.size() != 1) { System.out.println("C"); } else { System.out.println(llist.get(0)); } } //Template// // FAST I/O static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader( new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreElements()) { try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } double nextDouble() { return Double.parseDouble(next()); } String nextLine() { String str = ""; try { str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } return str; } } // Integer Sort static void sort(int[] a) { ArrayList<Integer> l=new ArrayList<>(); for (int i:a) l.add(i); Collections.sort(l); for (int i=0; i<a.length; i++) a[i]=l.get(i); } // Long Sort static void sort(long[] a) { ArrayList<Long> l=new ArrayList<>(); for (long i:a) l.add(i); Collections.sort(l); for (int i=0; i<a.length; i++) a[i]=l.get(i); } // boolean Value static void val(boolean val) { System.out.println(val ? "YES" : "NO"); System.out.flush(); } // GCD public static int GCD (int a, int b) { if(b == 0) return a ; return GCD(b, a%b) ; } // sieve public static boolean [] sieveofEratosthenes(int n) { boolean isPrime[] = new boolean[n+1] ; Arrays.fill(isPrime, true); isPrime[0] = false ; isPrime[1] = false ; for(int i = 2 ; i * i <= n ; i++) { for(int j = 2 * i ; j<= n ; j+= i) { isPrime[j] = false ; } } return isPrime ; } // fastPower public static long fastPowerModulo(long a, long b, long n) { long res = 1 ; while(b > 0) { if((b&1) != 0) { res = (res * a % n) % n ; } a = (a % n * a % n) % n ; b = b >> 1 ; } return res ; } }
JAVA
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
#include <bits/stdc++.h> using namespace std; void me() { std::ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); } void stop() {} long long gcd(long long a, long long b) { return !b ? a : gcd(b, a % b); } long long lcm(long long a, long long b) { return (a / gcd(a, b)) * b; } string convert(long long a) { int c = 0; string x = ""; while (a > 0) { x += a % 2 + '0'; a /= 2; c++; } return x; } bool isPrime(int n) { if (n <= 1) return false; for (int i = 2; i <= sqrt(n); i++) if (n % i == 0) return false; return true; } string strcon(long long n) { stringstream ss; ss << n; string str = ss.str(); return str; } int main() { int arr[4]; int fr[4]; for (int i = 0; i < 4; i++) { string x; cin >> x; arr[i] = x.size() - 2; fr[i] = x.size() - 2; } sort(arr, arr + 4); int x = 0, y = 0; if (arr[3] / 2 >= arr[1] && arr[3] / 2 >= arr[2] && arr[3] / 2 >= arr[0]) x = arr[3]; if (arr[1] / 2 >= arr[0] && arr[2] / 2 >= arr[0] && arr[3] / 2 >= arr[0]) y = arr[0]; if (x != 0 && y != 0 || x == 0 && y == 0) cout << "C" << "\n"; else { for (int i = 0; i < 4; i++) { if (fr[i] == max(x, y)) { cout << char(i + 65) << "\n"; } } } }
CPP
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
#include <bits/stdc++.h> using namespace std; int main() { int mi = INT_MAX, ma = 0, ri, ra, cnti = 0, cnta = 0; char s[5][105]; for (int i = 0; i < 4; i++) scanf("%s", s[i]); for (int i = 0; i < 4; i++) { if (strlen(s[i]) - 2 < mi) mi = strlen(s[i]) - 2, ri = i; } for (int i = 0; i < 4; i++) if (mi <= (strlen(s[i]) - 2) / 2) cnti++; for (int i = 0; i < 4; i++) { if (strlen(s[i]) - 2 > ma) ma = strlen(s[i]) - 2, ra = i; } for (int i = 0; i < 4; i++) if (ma >= (strlen(s[i]) - 2) * 2) cnta++; if (cnti >= 3 && cnta >= 3) printf("%c", s[2][0]); else if (cnti >= 3) printf("%c", s[ri][0]); else if (cnta >= 3) printf("%c", s[ra][0]); else printf("%c", s[2][0]); return 0; }
CPP
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
CHOICES = ['A', 'B', 'C', 'D'] lines = [] for i in range(4): lines.append(raw_input()) lengths = [] for line in lines: lengths.append(len(line) - 2) greats = [] for i in range(len(lines)): double = True half = True for j in range(len(lines)): if i != j: double = double and lengths[i] >= 2*lengths[j] half = half and lengths[i] <= .5*lengths[j] if double or half: greats.append(i) if len(greats) == 1: print CHOICES[greats[0]] else: print 'C'
PYTHON
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
#include <bits/stdc++.h> using namespace std; long long f(long long n) { long long res = 0; while (n) { if (n % 10 != 0) { res = res * 10 + (n % 10); } n /= 10; } long long rev = 0; while (res) { rev = (rev * 10) + (res % 10); res /= 10; } return rev; } int32_t main() { string s[4]; for (long long i = 0; i < 4; i++) cin >> s[i]; long long f[4] = {}; for (long long i = 0; i < 4; i++) { f[i] = s[i].length() - 2; } long long mx = 0, mn = 106; char big, small; for (long long i = 0; i < 4; i++) { if (mx < f[i]) { mx = f[i]; big = (char)(i + 'A'); } if (mn > f[i]) { mn = f[i]; small = (char)(i + 'A'); } } bool isbig = true, issmall = true; for (char c = 'A'; c <= 'D'; c++) { if (f[c - 'A'] * 2 > f[big - 'A'] && c != big) { isbig = false; } if (f[c - 'A'] < f[small - 'A'] * 2 && c != small) { issmall = false; } } if ((isbig ^ issmall) == 0) { cout << "C"; } else if (isbig == true) { cout << big; } else cout << small; }
CPP
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
#include <bits/stdc++.h> using namespace std; int main() { string s1, s2, s3, s4; cin >> s1 >> s2 >> s3 >> s4; int a = s1.length() - 2; int b = s2.length() - 2; int c = s3.length() - 2; int d = s4.length() - 2; int count = 0; char ans; if (2 * a <= b && 2 * a <= c && 2 * a <= d) { ans = 'A'; count++; } if (2 * b <= a && 2 * b <= c && 2 * b <= d) { ans = 'B'; count++; } if (2 * c <= a && 2 * c <= b && 2 * c <= d) { ans = 'C'; count++; } if (2 * d <= a && 2 * d <= b && 2 * d <= c) { ans = 'D'; count++; } if (a >= 2 * b && a >= 2 * c && a >= 2 * d) { ans = 'A'; count++; } if (b >= 2 * a && b >= 2 * c && b >= 2 * d) { ans = 'B'; count++; } if (c >= 2 * a && c >= 2 * b && c >= 2 * d) { ans = 'C'; count++; } if (d >= 2 * a && d >= 2 * b && d >= 2 * c) { count++; ans = 'D'; } if (count == 1) cout << ans; else cout << 'C'; return 0; }
CPP
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
import java.util.Scanner; public class ThechildandHomework { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Scanner input= new Scanner(System.in); String s1= input.next(); int t1 = s1.length()-2; String s2 = input.next(); int max=Integer.MIN_VALUE; int min =Integer.MAX_VALUE; int t2= s2.length()-2; if(t1<t2){min = t1;max = t2;} else { min = t2; max=t1; } String s3 = input.next(); int t3= s3.length()-2; if(t3<min)min = t3; if(t3>max)max = t3; String s4 = input.next(); int t4 = s4.length()-2; if(t4<min)min = t4; if(t4>max)max = t4; String z = "C"; //System.out.println(min+ " " + max); //System.out.println(t1 +" " + t2 + " " + t3 + " " +t4); boolean condition = false; if(min==t1 && 2*min<=t2 && 2*min<=t3 && 2*min<=t4 ){ if(!condition){z="A";condition = true;} else z="C"; } if(max==t1 && max>=2*t2 && max>=2*t3 && max>=2*t4){ if(!condition){z="A"; condition = true;} else z="C"; } //System.out.println("A");} if(min==t2 && 2*min<=t1 && 2*min<=t3 && 2*min<=t4){ if(!condition){z="B"; condition = true;} else z="C"; } //System.out.println("B");} if(max==t2 && max>=2*t1 && max>=2*t3 && max>=2*t4){ if(!condition){z="B";condition = true;} else z="C"; //System.out.println("B"); } if(min==t3 && 2*min<=t2 && 2*min<=t1 && 2*min<=t4){ if(!condition){z="C";condition = true;} else z="C"; } //System.out.println("C");} if(max==t3 && max>=2*t2 && max>=2*t1 && max>=2*t4){ if(!condition){z="C";condition = true;} else z="C"; //System.out.println("C"); } if(min==t4 && 2*min<=t2 && 2*min<=t3 && 2*min<=t1){ if(!condition){z="D";condition = true;} else z="C"; //System.out.println("D"); } if(max==t4 && max>=2*t2 && max>=2*t3 && max>=2*t1){ if(!condition){z="D";condition = true;} else z="C"; //System.out.println("D"); } System.out.println(z); } }
JAVA
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
import java.io.*; import java.util.Arrays; import java.util.*; import java.util.StringTokenizer; public class Main { PrintWriter out; BufferedReader input; Main() { try { input = new BufferedReader(new FileReader("input.txt")); out = new PrintWriter(new FileWriter("output.txt"), true); solver(); } catch (Exception ex) { ex.printStackTrace(); input = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out, true); solver(); } finally { out.close(); try { input.close(); } catch (IOException e) { e.printStackTrace(); } } } StringTokenizer st = new StringTokenizer(""); private String nextToken() { while (!st.hasMoreElements()) { try { st = new StringTokenizer(input.readLine()); } catch (IOException e) { e.printStackTrace(); } } return st.nextToken(); } private int nextInt() { return Integer.parseInt(nextToken()); } private long nextLong() { return Long.parseLong(nextToken()); } public void solver() { String s1 = nextToken(); String s2 = nextToken(); String s3 = nextToken(); String s4 = nextToken(); Pair[] p = new Pair[4]; p[0] = new Pair(s1.substring(0, 1), s1.length() - 2); p[1] = new Pair(s2.substring(0, 1), s2.length() - 2); p[2] = new Pair(s3.substring(0, 1), s3.length() - 2); p[3] = new Pair(s4.substring(0, 1), s4.length() - 2); Arrays.sort(p); boolean intwo = false; boolean intwo2 = false; if (p[0].len*2 <= p[1].len && p[0].len*2 <= p[2].len && p[0].len*2 <= p[3].len) { intwo = true; } if (p[3].len >= p[2].len*2 && p[3].len >= p[1].len*2 && p[3].len >= p[0].len*2) { intwo2 = true; } if (intwo && !intwo2) { out.println(p[0].s); } else if (!intwo && intwo2) { out.println(p[3].s); } else { out.println("C"); } } public static void main(String[] args) { new Main(); } } class Pair implements Comparable<Pair>{ String s; int len; Pair(String s_, int len_) { s = s_; len = len_; } @Override public int compareTo(Pair o) { return len-o.len; } }
JAVA
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
import java.util.Scanner; public class Main { public static void main(String[] args) { String str[]; str=new String[4]; Scanner in=new Scanner (System.in); int i,j,gc=0,ans = 0; boolean flag; for(i=0;i<4;i++) { str[i]=in.nextLine(); } for(i=0;i<4;i++) { //twice shorter flag=true; for(j=0;j<4;j++) { if(i==j) { continue; } if(str[i].length()-2>(str[j].length()-2)/2) { flag=false; break; } } if(flag==true) { gc++; ans=i; continue; } //twice large flag=true; for(j=0;j<4;j++) { if(i==j) continue; if(str[i].length()-2<(str[j].length()-2)*2) { flag=false; break; } } if(flag==true) { gc++; ans=i; continue; } } if(gc==1) { char a=(char) ('A'+ans); System.out.println(a); } else { System.out.println('C'); } } }
JAVA
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ import java.util.*; import java.io.*; public class NewMain_113 { public static void main(String[] args) { // TODO code application logic here FastReader s = new FastReader(); String[] an = new String[4]; int[] len = new int[4]; for (int i = 0; i < 4; i++) { an[i] = s.next().substring(2); len[i] = an[i].length(); } Arrays.sort(len); boolean twiceShort = true, twiceLong = true; for (int i = 1; i < 4; i++) { if (len[0] == len[i]) { twiceShort = false; break; } if (len[i] < (len[0] * 2)) { twiceShort = false; break; } } for (int i = 0; i < 3; i++) { if (len[3] == len[i]) { twiceLong = false; break; } if (len[3] < (len[i] * 2)) { twiceLong = false; break; } } String[] a = {"A", "B", "C", "D"}; // System.out.println(twiceShort + " " + twiceLong); // System.out.println(Arrays.toString(len)); if ((twiceLong && twiceShort) || (!twiceShort && !twiceLong)) { System.out.println("C"); return; } if (twiceShort) { for (int i = 0; i < 4; i++) { if (an[i].length() == len[0]) { System.out.println(a[i]); return; } } } else if (twiceLong) { for (int i = 0; i < 4; i++) { if (an[i].length() == len[3]) { System.out.println(a[i]); return; } } } } static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreElements()) { try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } double nextDouble() { return Double.parseDouble(next()); } String nextLine() { String str = ""; try { str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } return str; } } }
JAVA
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
import logging import copy import sys import math logging.basicConfig(stream=sys.stderr, level=logging.DEBUG) # def solve(firstLine): def solve(lines): l = list(map(lambda x: len(x[2:]), lines)) min_len = min(l) great = [] others = list(filter(lambda x: x >= 2 * min_len, l)) if len(others) == 3: great.append(l.index(min_len)) max_len = max(l) others = list(filter(lambda x: 2 * x <= max_len,l)) if len(others) == 3: great.append(l.index(max_len)) if len(great) == 1: return "ABCD"[great[0]] return "C" def main(): lines = [] for i in range(0, 4): lines.append(input()) print(solve(lines)) def log(*message): logging.debug(message) if __name__ == "__main__": main()
PYTHON3
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
#include <bits/stdc++.h> using namespace std; const int MOD(1000000007); const int INF((1 << 30) - 1); const int MAXN(); int a[4]; int main() { for (int i = 0; i < 4; i++) { string s; cin >> s; a[i] = s.size() - 2; } int ans = -1, cnt = 0; for (int i = 0; i < 4; i++) { int p1 = 0, p2 = 0; for (int j = 0; j < 4; j++) { if (i == j) continue; if (a[i] * 2 <= a[j]) p1++; if (a[i] >= a[j] * 2) p2++; } if (p1 == 3 || p2 == 3) { ans = i; cnt++; } } printf("%c", (cnt == 1) ? (ans + 'A') : 'C'); }
CPP
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
Astr = input() Bstr = input() Cstr = input() Dstr = input() A_len = len(Astr[2:]) B_len = len(Bstr[2:]) C_len = len(Cstr[2:]) D_len = len(Dstr[2:]) arr = [A_len, B_len, C_len, D_len] det = "ABCD" last_det = [] for i in range(4): last_arr = arr.copy() last_arr.pop(i) if arr[i] >= 2 * last_arr[0] and arr[i] >= 2 * last_arr[1] and arr[i] >= 2 * last_arr[2]: last_det.append(det[i]) for j in range(4): last_arr = arr.copy() last_arr.pop(j) if arr[j] <= 1 / 2 * last_arr[0] and arr[j] <= 1 / 2 * last_arr[1] and arr[j] <= 1 / 2 * last_arr[2]: last_det.append(det[j]) if len(last_det) == 1: print(last_det[0]) else: print("C")
PYTHON3
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
Astr = input() Bstr = input() Cstr = input() Dstr = input() A_len = len(Astr[2:]) B_len = len(Bstr[2:]) C_len = len(Cstr[2:]) D_len = len(Dstr[2:]) arr = [A_len, B_len, C_len, D_len] det="ABCD" last_det=[] for i in range(4): last_arr=arr.copy() last_arr.pop(i) if arr[i] >= 2 * last_arr[0] and arr[i] >= 2 * last_arr[1] and arr[i] >= 2 * last_arr[2]: # print(det[i]) last_det.append(det[i]) for j in range(4): last_arr=arr.copy() last_arr.pop(j) if arr[j] <= 1/2 * last_arr[0] and arr[j] <= 1/2 * last_arr[1] and arr[j] <= 1/2 * last_arr[2]: # print(det[j]) last_det.append(det[j]) if len(last_det) ==1: print(last_det[0]) else: print("C")
PYTHON3
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
#include <bits/stdc++.h> using namespace std; int main() { int i, j, k; string s[4]; for (i = 0; i < 4; i++) cin >> s[i]; int sizes[4]; for (i = 0; i < 4; i++) sizes[i] = s[i].size() - 2; sort(sizes, sizes + 4); if (sizes[0] <= 0.5 * sizes[1] && sizes[3] < 2 * sizes[2]) { for (i = 0; i < 4; i++) { if (s[i].size() - 2 == sizes[0]) cout << s[i][0]; } } else if (sizes[3] >= 2 * sizes[2] && sizes[0] > 0.5 * sizes[1]) { for (i = 0; i < 4; i++) { if (s[i].size() - 2 == sizes[3]) cout << s[i][0]; } } else cout << "C"; }
CPP
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
a= raw_input() b= raw_input() c= raw_input() d = raw_input() l =[[len(a)-2,"A"], [len(b)-2,"B"],[len(c)-2,"C"],[len(d)-2,"D"]] l.sort() if 2* l[0][0] <= l[1][0] and 2*l[2][0] <= l[3][0]: print("C") elif 2* l[0][0] <= l[1][0]: print (l[0][1]) elif 2 * l[2][0] <= l[3][0]: print (l[3][1]) else: print ("C")
PYTHON
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
#include <bits/stdc++.h> using namespace std; const int maxn = 1e6 + 100; int val[maxn]; long long res = 0; int main() { ios::sync_with_stdio(false); string s[4]; cin >> s[0] >> s[1] >> s[2] >> s[3]; pair<int, char> l[4]; for (int i = 0; i < 4; i++) { l[i].first = s[i].size() - 2; l[i].second = 'A' + i; } sort(l, l + 4); bool agood = l[0].first * 2 <= l[1].first; bool bgood = l[2].first * 2 <= l[3].first; if (agood == bgood) { cout << 'C'; } else if (agood) { cout << l[0].second; } else if (bgood) { cout << l[3].second; } }
CPP
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
#include <bits/stdc++.h> using namespace std; template <class T1> void deb(T1 e) { cout << e << endl; } template <class T1, class T2> void deb(T1 e1, T2 e2) { cout << e1 << " " << e2 << endl; } template <class T1, class T2, class T3> void deb(T1 e1, T2 e2, T3 e3) { cout << e1 << " " << e2 << " " << e3 << endl; } template <class T1, class T2, class T3, class T4> void deb(T1 e1, T2 e2, T3 e3, T4 e4) { cout << e1 << " " << e2 << " " << e3 << " " << e4 << endl; } template <class T1, class T2, class T3, class T4, class T5> void deb(T1 e1, T2 e2, T3 e3, T4 e4, T5 e5) { cout << e1 << " " << e2 << " " << e3 << " " << e4 << " " << e5 << endl; } template <class T1, class T2, class T3, class T4, class T5, class T6> void deb(T1 e1, T2 e2, T3 e3, T4 e4, T5 e5, T6 e6) { cout << e1 << " " << e2 << " " << e3 << " " << e4 << " " << e5 << " " << e6 << endl; } int main() { int i, j, a, b, c, d, con; string ans; string st; con = 0; cin >> st; a = st.size() - 2; cin >> st; b = st.size() - 2; cin >> st; c = st.size() - 2; cin >> st; d = st.size() - 2; if ((a >= (2 * b) && a >= (2 * c) && a >= (2 * d)) || ((2 * a) <= b && (2 * a) <= c && (2 * a) <= d)) { con++; ans = "A"; } if ((b >= (2 * c) && b >= (2 * d) && b >= (2 * a)) || ((2 * b) <= a && (2 * b) <= d && (2 * b) <= c)) { con++; ans = "B"; } if ((c >= (2 * b) && c >= (2 * a) && c >= (2 * d)) || ((2 * c) <= a && (2 * c) <= b && (2 * c) <= d)) { con++; ans = "C"; } if ((d >= (2 * b) && d >= (2 * c) && d >= (2 * a)) || ((2 * d) <= a && (2 * d) <= b && (2 * d) <= c)) { con++; ans = "D"; } if (con == 1) cout << ans; else cout << "C"; return 0; }
CPP
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
#include <bits/stdc++.h> using namespace std; const int MaxLength = 10001; typedef int arr[MaxLength]; string read_string() { static char s[MaxLength]; gets(s); string st = ""; for (int i = 0; s[i]; i++) st += s[i]; return st; } int main() { string s1 = read_string(), s2 = read_string(), s3 = read_string(), s4 = read_string(); static arr a, b = {0}; a[1] = s1.length() - 2; a[2] = s2.length() - 2; a[3] = s3.length() - 2; a[4] = s4.length() - 2; for (int i = 1; i <= 4; i++) { bool flag = true; for (int j = 1; j <= 4; j++) if (i != j && a[i] < 2 * a[j]) flag = false; bool flag2 = true; for (int j = 1; j <= 4; j++) if (i != j && 2 * a[i] > a[j]) flag2 = false; if (flag || flag2) b[i] = 1; } int c = 0, memi; for (int i = 1; i <= 4; i++) if (b[i] == 1) { memi = i; c++; } if (c == 1) printf("%c", 'A' + memi - 1); else printf("C"); return 0; }
CPP
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
#include <bits/stdc++.h> using namespace std; int a[4], knt, p; char s[4][210]; int main() { scanf("%s%s%s%s", s[0], s[1], s[2], s[3]); for (int i = 0; i < 4; i++) a[i] = strlen(s[i]) - 2; int flag[4] = {'A', 'B', 'C', 'D'}; for (int i = 0; i < 4; i++) { int cnt = 0, rnt = 0; for (int j = 0; j < 4; j++) { if (i == j) continue; if (a[i] >= 2 * a[j]) cnt++; if (a[i] * 2 <= a[j]) rnt++; } if (cnt == 3 or rnt == 3) { p = i; knt++; } } if (knt == 1) printf("%c\n", flag[p]); else puts("C"); return 0; }
CPP
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
import java.io.InputStreamReader; import java.io.IOException; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top */ public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); PrintWriter out = new PrintWriter(outputStream); TaskA solver = new TaskA(); solver.solve(1, in, out); out.close(); } } class TaskA { public void solve(int testNumber, InputReader in, PrintWriter out) { String []s = new String[]{in.next(),in.next(),in.next(),in.next()}; int []le = new int[]{s[0].substring(2).length(),s[1].substring(2).length(),s[2].substring(2).length(),s[3].substring(2).length()}; int cur = 0; int ans = -1; String res = "ABCD"; for (int i = 0; i < 4; i++) { int ss = 0; int ll = 0; for (int j = 0; j < 4; j++) { if (i == j)continue; if (le[i]*2 <= le[j])ss++; if (le[i] >= 2*le[j])ll++; } if ((ss == 3 || ll == 3)){ ans = i; cur++; } } if (cur == 1){ out.print(res.charAt(ans)); } else out.print("C"); } } class InputReader { public BufferedReader reader; public StringTokenizer tokenizer; public InputReader(InputStream stream) { reader = new BufferedReader(new InputStreamReader(stream)); tokenizer = null; } public String next() { while (tokenizer == null || !tokenizer.hasMoreTokens()) { try { tokenizer = new StringTokenizer(reader.readLine()); } catch (IOException e) { throw new RuntimeException(e); } } return tokenizer.nextToken(); } }
JAVA
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * * @author Pranay2516 */ public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; FastReader in = new FastReader(inputStream); PrintWriter out = new PrintWriter(outputStream); TaskA solver = new TaskA(); solver.solve(1, in, out); out.close(); } static class TaskA { public void solve(int testNumber, FastReader in, PrintWriter out) { char a[] = in.next().toCharArray(); char b[] = in.next().toCharArray(); char c[] = in.next().toCharArray(); char d[] = in.next().toCharArray(); int al = a.length - 2, bl = b.length - 2, cl = c.length - 2, dl = d.length - 2; int ans = 0; String f = ""; if ((al >= 2 * bl && al >= 2 * cl && al >= 2 * dl) || (2 * al <= bl && 2 * al <= cl && 2 * al <= dl)) { f = "A"; ans++; } if ((bl >= 2 * al && bl >= 2 * cl && bl >= 2 * dl) || (2 * bl <= al && 2 * bl <= cl && 2 * bl <= dl)) { f = "B"; ans++; } if ((cl >= 2 * bl && cl >= 2 * al && cl >= 2 * dl) || (2 * cl <= bl && 2 * cl <= al && 2 * cl <= dl)) { f = "C"; ans++; } if ((dl >= 2 * bl && dl >= 2 * cl && dl >= 2 * al) || (2 * dl <= bl && 2 * dl <= cl && 2 * dl <= al)) { f = "D"; ans++; } out.println(ans == 1 ? f : "C"); } } static class FastReader { private InputStream stream; private byte[] buf = new byte[1024]; private int curChar; private int numChars; private FastReader.SpaceCharFilter filter; public FastReader(InputStream stream) { this.stream = stream; } public int read() { if (numChars == -1) throw new InputMismatchException(); if (curChar >= numChars) { curChar = 0; try { numChars = stream.read(buf); } catch (IOException e) { throw new InputMismatchException(); } if (numChars <= 0) return -1; } return buf[curChar++]; } public String next() { int c = read(); while (isSpaceChar(c)) c = read(); StringBuilder res = new StringBuilder(); do { res.appendCodePoint(c); c = read(); } while (!isSpaceChar(c)); return res.toString(); } public boolean isSpaceChar(int c) { if (filter != null) return filter.isSpaceChar(c); return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1; } public interface SpaceCharFilter { public boolean isSpaceChar(int ch); } } }
JAVA
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.Arrays; import java.util.Comparator; public class A { static class t { char i; String s; t(char i, String s) {this.i=i; this.s=s;} } static StringBuilder sb=new StringBuilder(); static void parse(String l, int[] here) { sb.setLength(0); int len=l.length(), j=0; for (int i=0; i<len; i++) { char c=l.charAt(i); if(c==' ') { here[j++]=Integer.parseInt(sb.toString()); sb.setLength(0); } else { sb.append(c); } } if(sb.length()>0) { here[j++]=Integer.parseInt(sb.toString()); } } static void run_stream(InputStream ins) throws IOException { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); t[] q=new t[4]; for (int i=0; i<q.length; i++) { q[i]=new t((char)('A'+i), br.readLine().substring(2)); } Arrays.sort(q, new Comparator<t>() { public int compare(t o1, t o2) { return o1.s.length()-o2.s.length(); }}); if(2*q[0].s.length()<=q[1].s.length()) { if(2*q[2].s.length()<=q[3].s.length()) { System.out.println("C"); } else { System.out.println(q[0].i); } } else if(2*q[2].s.length()<=q[3].s.length()) { System.out.println(q[3].i); } else { System.out.println("C"); } } public static void main(String[] args) throws IOException { run_stream(System.in); } }
JAVA
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * * @author neuivn */ public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); PrintWriter out = new PrintWriter(outputStream); TaskA solver = new TaskA(); solver.solve(1, in, out); out.close(); } static class TaskA { public void solve(int testNumber, InputReader in, PrintWriter out) { int A = (in.nextLine().substring(2)).length(); int B = (in.nextLine().substring(2)).length(); int C = (in.nextLine().substring(2)).length(); int D = (in.nextLine().substring(2)).length(); int a = 0; int b = 0; int c = 0; int d = 0; if (A * 2 <= B && A * 2 <= C && A * 2 <= D) { ++a; } else if (A >= B * 2 && A >= C * 2 && A >= D * 2) { ++a; } if (B * 2 <= A && B * 2 <= C && B * 2 <= D) { ++b; } else if (B >= A * 2 && B >= C * 2 && B >= D * 2) { ++b; } if (C * 2 <= A && C * 2 <= B && C * 2 <= D) { ++c; } else if (C >= A * 2 && C >= B * 2 && C >= D * 2) { ++c; } if (D * 2 <= A && D * 2 <= B && D * 2 <= C) { ++d; } else if (D >= A * 2 && D >= B * 2 && D >= C * 2) { ++d; } if ((a + b + c + d) != 1) { out.println("C"); } else { if (a == 1) out.println("A"); else if (b == 1) out.println("B"); else if (d == 1) out.println("D"); else out.println("C"); } } } static class InputReader { public BufferedReader reader; public StringTokenizer tokenizer; public InputReader(InputStream stream) { reader = new BufferedReader(new InputStreamReader(stream), 32768); tokenizer = null; } public String nextLine() { try { return reader.readLine(); } catch (IOException e) { e.printStackTrace(); } return null; } } }
JAVA
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
keys = [] values = [] for i in range(4): k,v = input().split(".") values.append(v) keys.append(k) great = [] for i in range(4): c = 0 for j in range(4): if i!=j and len(values[i]) <= 0.5 * len(values[j]): c += 1 if i!=j and len(values[i]) >= 2 * len(values[j]): c -= 1 if c == 3 or c== -3: great.append(keys[i]) if len(great) == 1: print(great[0]) else: print("C")
PYTHON3
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
/** * Created by den on 6/1/14. */ import java.io.*; import java.util.*; public class A extends Thread { private void solve() throws IOException { int[] ansLength = new int[4]; String[] ans = new String[4]; for (int i = 0; i < 4; i++) { ans[i] = nextToken(); ansLength[i] = ans[i].length() - 2; } Arrays.sort(ansLength); int length = -1; if (ansLength[0] * 2 <= ansLength[1] && ansLength[2] * 2 > ansLength[3]) { length = ansLength[0]; } if (ansLength[0] * 2 > ansLength[1] && ansLength[2] * 2 <= ansLength[3]) { length = ansLength[3]; } if (length > -1) { for (int i = 0; i < 4; i++) if (ans[i].length()-2 == length) out.println(ans[i].charAt(0)); } else{ out.println("C"); } } public void run() { try { solve(); } catch (Exception e) { System.out.println("System exiting...."); e.printStackTrace(); System.exit(888); } finally { out.flush(); out.close(); } } public static void main(String[] args) throws FileNotFoundException { new A().run(); } public A() throws FileNotFoundException { //in = new BufferedReader(new FileReader("A-large.in")); //out = new PrintWriter(new File("A-large.out")); in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); setPriority(Thread.MAX_PRIORITY); } private BufferedReader in; private PrintWriter out; private StringTokenizer st; private int _int() throws IOException { return Integer.parseInt(nextToken()); } private double _double() throws IOException { return Double.parseDouble(nextToken()); } private long _long() throws IOException { return Long.parseLong(nextToken()); } private char[] _chars() throws IOException { return nextToken().toCharArray(); } private String nextToken() throws IOException { if (st == null || !st.hasMoreElements()) st = new StringTokenizer(in.readLine(), " \t\r\n"); return st.nextToken(); } }
JAVA
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
l1=[] for i in range(4): l1.append((len(input())-2,i)) l1.sort() ans1,ans2=-1,-1 if 2*l1[0][0]<=l1[1][0]: ans1=l1[0][1] if 2*l1[2][0]<=l1[3][0]: ans2=l1[3][1] if ans1==-1 and ans2==-1: print('C') elif ans1!=-1 and ans2!=-1: print('C') else : if ans1==-1: print(chr(ans2+65)) else : print(chr(ans1+65))
PYTHON3
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
import java.util.*; // "static void main" must be defined in a public class. public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String[] ans = new String[4]; ans[0] = "A"; ans[1] = "B"; ans[2] = "C"; ans[3] = "D"; int flag = 0; String result = ""; String[] s = new String[4]; for(int i=0;i<s.length;i++){ s[i] = sc.nextLine(); } for(int i=0;i<s.length;i++){ int n = s[i].length()-2; int count_more = 0, count_less = 0; for(int j=0;j<s.length;j++){ if(i==j) continue; if(s[j].length()-2>=2*n) count_more++; if(s[j].length()-2<=(n/2)) count_less++; } if(count_more == s.length-1 || count_less == s.length-1) { if(result.equals("")){ result=ans[i]; flag = 1; } else flag = 0; } } if(flag == 1){ System.out.println(result); } if(flag==0) System.out.println("C"); } }
JAVA
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
from __future__ import print_function w,a = raw_input().split('.') w,b = raw_input().split('.') w,c = raw_input().split('.') w,d = raw_input().split('.') l=[] l.append(len(a)) l.append(len(b)) l.append(len(c)) l.append(len(d)) l.sort() cn=0 res="" if (2*l[0]<=l[1]): if len(a)==l[0]: res+='A' elif len(b)==l[0]: res+='B' elif len(c)==l[0]: res+='C' elif len(d)==l[0]: res+='D' cn+=1 if (l[3]>=2*l[2]): if len(a)==l[3]: res+='A' elif len(b)==l[3]: res+='B' elif len(c)==l[3]: res+='C' elif len(d)==l[3]: res+='D' cn+=1 if (cn==1):print(res) else: print('C',end='')
PYTHON
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
# coding: utf-8 # (C) 2014, Laybson Plismenn / UFCG a = raw_input() b = raw_input() c = raw_input() d = raw_input() l = [len(a[2:]), len(b[2:]), len(c[2:]), len(d[2:])] m = "" n = "" for i in xrange(len(l)): maior = 0 menor = 0 for j in xrange(len(l)): if l[i] <= l[j] / 2.0: menor += 1 if menor == 3: if i == 0: n = "A" break elif i == 1: n = "B" break elif i == 2: n = "C" break else: n = "D" break for j in xrange(len(l)): if l[i] >= l[j] * 2.0: maior += 1 if maior == 3: if i == 0: m = "A" break elif i == 1: m = "B" break elif i == 2: m = "C" break else: m = "D" break menor = 0 maior = 0 if len(m) != 0 and len(n) != 0: print "C" elif len(m) == 0 and len(n) == 0: print "C" elif len(m) == 0: print n elif len(n) == 0: print m
PYTHON
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
a = input() b = input() c = input() d = input() eles = [a, b , c , d] elems = [a[2:], b[2:], c[2:], d[2:]] #print(elems) g = [] l = [len(elems[0]),len(elems[1]), len(elems[2]), len(elems[3])] #print(l) for i in range(4): ele = l[i] r = [] for j in range(4): if i == j : continue else: ratio = ele / l[j] #print(ratio) r.append(ratio) #print(r) count = 0 for k in range(len(r)): if r[k] <= 0.5 : count += 1 if count == 3 : g.append(i) else: count1 = 0 for c in range(len(r)): if r[c] >= 2: count1 += 1 if count1 == 3: g.append(i) if len(g) == 1: print(eles[g[0]][0]) else: print("C")
PYTHON3
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
__author__ = 'forevercode' CevapA = [str(temp) for temp in raw_input().split(".")] CevapB = [str(temp) for temp in raw_input().split(".")] CevapC = [str(temp) for temp in raw_input().split(".")] CevapD = [str(temp) for temp in raw_input().split(".")] Cevaplar = [int(s) for s in range(0, 4)] tempCevaplar = [0 for temp in range(0, 4)] tempCevaplar[0] = len(CevapA[1]) tempCevaplar[1] = len(CevapB[1]) tempCevaplar[2] = len(CevapC[1]) tempCevaplar[3] = len(CevapD[1]) Cevaplar[0] = len(CevapA[1]) Cevaplar[1] = len(CevapB[1]) Cevaplar[2] = len(CevapC[1]) Cevaplar[3] = len(CevapD[1]) tempCevaplar.sort() i = 0 current = 0 bool = None result = 0 if tempCevaplar[0] * 2 <= tempCevaplar[1]: sTemp = tempCevaplar[0] bool = True for m in range(len(Cevaplar)): if sTemp == Cevaplar[m]: result = m break if tempCevaplar[3] >= 2 * tempCevaplar[2]: result = 2 elif tempCevaplar[3] >= 2 * tempCevaplar[2]: sTemp = tempCevaplar[3] bool = True for m in range(len(Cevaplar)): if sTemp == Cevaplar[m]: result = m break if tempCevaplar[0] * 2 <= tempCevaplar[1]: result = 2 else: bool = True result = 2 if bool: if result == 0: print "A" elif result == 1: print "B" elif result == 2: print "C" elif result == 3: print "D"
PYTHON
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
import java.io.*; import java.util.*; public class test { int INF = (int)1e9; long MOD = 1000000007; void solve(InputReader in, PrintWriter out) throws IOException { String a = in.next().substring(2); String b = in.next().substring(2); String c = in.next().substring(2); String d = in.next().substring(2); int rs = 0, cnt = 0; int al=a.length(), bl=b.length(), cl=c.length(), dl=d.length(); if(2*al<=bl && 2*al<=cl && 2*al<=dl) {rs=0; cnt++;} if(al>=2*bl && al>=2*cl && al>=2*dl) {rs=0; cnt++;} if(2*bl<=al && 2*bl<=cl && 2*bl<=dl) {rs=1; cnt++;} if(bl>=2*al && bl>=2*cl && bl>=2*dl) {rs=1; cnt++;} if(2*cl<=bl && 2*cl<=al && 2*cl<=dl) {rs=2; cnt++;} if(cl>=2*bl && cl>=2*al && cl>=2*dl) {rs=2; cnt++;} if(2*dl<=bl && 2*dl<=cl && 2*dl<=al) {rs=3; cnt++;} if(dl>=2*bl && dl>=2*cl && dl>=2*al) {rs=3; cnt++;} if(cnt==1) out.println((char)('A'+rs)); else out.println("C"); } public static void main(String[] args) throws IOException { if(args.length>0 && args[0].equalsIgnoreCase("d")) { DEBUG_FLAG = true; } InputReader in = new InputReader(); PrintWriter out = new PrintWriter(System.out); int t = 1;//in.nextInt(); long start = System.nanoTime(); while(t-- >0) { new test().solve(in, out); } long end = System.nanoTime(); debug("\nTime: " + (end-start)/1e6 + " \n\n"); out.close(); } static boolean DEBUG_FLAG = false; static void debug(String s) { if(DEBUG_FLAG) System.out.print(s); } static class InputReader { static BufferedReader br; static StringTokenizer st; public InputReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreTokens()) { try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } double nextDouble() { return Double.parseDouble(next()); } } }
JAVA
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int s=Integer.MAX_VALUE,s2=Integer.MAX_VALUE,l=0,l2=0; String arr[]=new String[4]; char a='a',b='b'; for(int i=0;i<4;i++) { arr[i]=sc.next(); int n=arr[i].length()-2; if(n<=s) { s2=s; s=n; a=arr[i].charAt(0); } else if(n>s && s2>n) s2=n; if(l<=n) { l2=l; l=n; b=arr[i].charAt(0); } else if(n<l && l2<n) l2=n; } if(l>=2*l2 && 2*s>s2 ) { System.out.println(b); return; } else if(s*2<=s2 && l<2*l2) { System.out.println(a); return; } System.out.println('C'); } }
JAVA
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
#include <bits/stdc++.h> using namespace std; int main() { string a, b, c, d; cin >> a >> b >> c >> d; long long n[4], m[4]; m[0] = n[0] = a.length() - 2; m[1] = n[1] = b.length() - 2; m[2] = n[2] = c.length() - 2; m[3] = n[3] = d.length() - 2; sort(n, n + 4); if (2 * n[0] <= n[1] and 2 * n[2] > n[3]) { if (n[0] == m[0]) { cout << "A"; } else if (n[0] == m[1]) { cout << "B"; } else if (n[0] == m[2]) { cout << "C"; } else { cout << "D"; } } else if (2 * n[0] > n[1] and 2 * n[2] <= n[3]) { if (n[3] == m[0]) { cout << "A"; } else if (n[3] == m[1]) { cout << "B"; } else if (n[3] == m[2]) { cout << "C"; } else { cout << "D"; } } else { cout << "C"; } return 0; }
CPP
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Scanner; public class A { public static int solve(String[] choices, int[] len){ boolean []bestMore = new boolean[4]; boolean []bestLess = new boolean[4]; boolean bestM = true; boolean bestL = true; for(int j = 0; j < 4; j++){ bestMore[j] = true; bestLess[j] = true; } int countBest = 0; for(int i = 0; i < 4; i++){ bestM = true; for(int j = 0; j < 4; j++){ if(i != j){ bestMore[i] = bestMore[i] && len[i] >= len[j] * 2 ? true: false; bestM = bestM && bestMore[i]; } } if(bestM){ countBest++; } } for(int i = 0; i < 4; i++){ bestL = true; for(int j = 0; j < 4; j++){ if(i != j){ bestLess[i] = bestLess[i] && len[i]*2 <= len[j] ? true: false; bestL = bestL && bestLess[i]; } } if(bestL){ countBest++; } } if(countBest == 0 || countBest > 1){ return 2; } for(int i = 0; i < 4; i++){ if(bestMore[i]){ return i; } } for(int i = 0; i < 4; i++){ if(bestLess[i]){ return i; } } return 2; } public static void main(String[] args) { BufferedReader br = null; try { // br = new BufferedReader(new FileReader("input.txt")); br = new BufferedReader(new InputStreamReader(System.in)); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } Scanner in = new Scanner(br); String line; String []choices = new String[4]; int []len = new int[4]; while (in.hasNext()) { for(int i = 0; i < 4; i++){ line = in.nextLine().split("\\.")[1]; choices[i] = line; len[i] = choices[i].length(); } String x = "ABCD"; System.out.println(x.charAt(solve(choices, len))); } in.close(); } }
JAVA
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
#include <bits/stdc++.h> using namespace std; int used[100001]; int main() { string a[4]; for (long long i = 0; i < 4; i++) cin >> a[i]; int cnt = 0; int nom = 2; for (long long i = 0; i < 4; i++) { int ok1 = 0; int ok2 = 0; for (long long j = 0; j < 4; j++) if (i != j) { if ((a[i].size() - 2) * 2 <= (a[j].size() - 2)) ok1++; if ((a[i].size() - 2) >= (a[j].size() - 2) * 2) ok2++; } if (ok1 == 3) cnt++, nom = i; if (ok2 == 3) cnt++, nom = i; } if (cnt == 1) cout << a[nom][0]; else cout << "C"; }
CPP
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
a = input() b = input() c = input() d = input() cnta=0 cntb=0 cntc=0 cntd=0 x = len(a)-2 y = len(b)-2 z = len(c)-2 w = len(d)-2 #print(x,y,z,w) if (x>=2*y and x>=2*z and x>=2*w) or (2*x<=y and 2*x<=z and 2*x<=w): cnta+=1 if (y>=2*x and y>=2*z and y>=2*w) or (2*y<=x and 2*y<=z and 2*y<=w): cntb+=1 if (z>=2*y and z>=2*x and z>=2*w) or (2*z<=y and 2*z<=x and 2*z<=w): cntc+=1 if (w>=2*y and w>=2*z and w>=2*x) or (2*w<=y and 2*w<=z and 2*w<=x): cntd+=1 #print(cnta,cntb,cntc,cntd) if cnta>cntb and cnta>cntc and cnta>cntd: print("A") elif cntb>cnta and cntb>cntc and cntb>cntd: print("B") elif cntc>cnta and cntc>cntb and cntc>cntd: print("C") elif cntd>cnta and cntd>cntb and cntd>cntc: print("D") else: print("C")
PYTHON3
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
A=len(raw_input())-2 B=len(raw_input())-2 C=len(raw_input())-2 D=len(raw_input())-2 count=0 flag_A=False flag_B=False flag_C=False flag_D=False if(A >= 2*B and A >= 2*C and A >= 2*D): flag_A=True count+=1 if(2*A <= B and 2*A <= C and 2*A <= D): flag_A=True count+=1 if(B >= 2*A and B >= 2*C and B >= 2*D): flag_B=True count+=1 if(2*B <= A and 2*B <= C and 2*B <= D): flag_B=True count+=1 if(C >= 2*B and C >= 2*D and C >= 2*A): flag_C=True count+=1 if(2*C <= B and 2*C <= D and 2*C <= A): flag_C=True count+=1 if(D >= 2*B and D >= 2*C and D >= 2*A): flag_D=True count+=1 if(2*D <= B and 2*D <= C and 2*D <= A): flag_D=True count+=1 if(count>1 or count==0): print "C" elif(flag_A): print "A" elif(flag_B): print "B" elif(flag_C): print "C" elif(flag_D): print "D"
PYTHON
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
a = [len(input().strip()[2:]) for i in range(4)] wond = set() for i in range(4): good = 1 for j in range(4): if i != j and a[i] > a[j] // 2: good = 0 if good: wond.add(i) for i in range(4): good = 1 for j in range(4): if i != j and a[i] // 2 < a[j]: good = 0 if good: wond.add(i) d = {0:'A', 1:'B', 2:'C', 3:'D'} if len(wond) != 1: print('C') else: print(d[list(wond)[0]])
PYTHON3