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
#include <bits/stdc++.h> using namespace std; int main() { int m1 = 0, m2 = 0, mi1 = 1111, mi2 = 11111, l[7], c, d; string s[5]; for (int i = 0; i < 4; i++) { cin >> s[i]; l[i] = s[i].length() - 2; if (l[i] >= m1) { m1 = l[i]; c = i; } if (l[i] <= mi1) { mi1 = l[i]; d = i; } } bool ch1 = 0, ch2 = 0; for (int i = 0; i < 4; i++) if (i != c) if (m1 < l[i] * 2) ch1 = 1; for (int i = 0; i < 4; i++) if (i != d) if (mi1 > l[i] / 2) ch2 = 1; if (!ch1 && !ch2) cout << "C" << endl; else if (!ch1) cout << (char)(c + 'A') << endl; else if (!ch2) cout << (char)(d + 'A') << 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; char maxop(int lenA, int lenB, int lenC, int lenD) { char maxoption = 'a'; if (lenC >= 2 * lenB && lenC >= 2 * lenA && lenC >= 2 * lenD) maxoption = 'C'; else if (lenB >= 2 * lenA && lenB >= 2 * lenC && lenB >= 2 * lenD) maxoption = 'B'; else if (lenA >= 2 * lenB && lenA >= 2 * lenC && lenA >= 2 * lenD) maxoption = 'A'; else if (lenD >= 2 * lenB && lenD >= 2 * lenC && lenD >= 2 * lenA) maxoption = 'D'; return maxoption; } char minop(int lenA, int lenB, int lenC, int lenD) { char minoption = 'a'; if (2 * lenC <= lenB && 2 * lenC <= lenA && 2 * lenC <= lenD) minoption = 'C'; else if (2 * lenB <= lenA && 2 * lenB <= lenC && 2 * lenB <= lenD) minoption = 'B'; else if (2 * lenA <= lenB && 2 * lenA <= lenC && 2 * lenA <= lenD) minoption = 'A'; else if (2 * lenD <= lenB && 2 * lenD <= lenC && 2 * lenD <= lenA) minoption = 'D'; return minoption; } int main() { string A, B, C, D; cin >> A >> B >> C >> D; int lenA = A.length() - 2; int lenB = B.length() - 2; int lenC = C.length() - 2; int lenD = D.length() - 2; char maxoption = 'a', minoption = 'a'; maxoption = maxop(lenA, lenB, lenC, lenD); minoption = minop(lenA, lenB, lenC, lenD); if (minoption == 'a' && maxoption == 'a') cout << 'C' << endl; else if (minoption == 'a' && maxoption != 'a') cout << maxoption << endl; else if (minoption != 'a' && maxoption == 'a') cout << minoption << endl; else if (minoption != 'a' && maxoption != 'a') 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
a=input() b=input() c=input() d=input() l=[[len(a)-2,'A'],[len(b)-2,'B'],[len(c)-2,'C'],[len(d)-2,'D']] l = sorted(l) tmp = 0 if l[0][0]*2 <= l[1][0] and not l[-1][0] >= l[-2][0]*2: print(l[0][1]) elif l[-1][0] >= l[-2][0]*2 and not l[0][0]*2 <= l[1][0]: print(l[-1][1]) 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 = input() na = len(a) - 2 b = input() nb = len(b) - 2 c = input() nc = len(c) - 2 d = input() nd = len(d) - 2 a = a[2:] b = b[2:] c = c[2:] d = d[2:] al = a.lower() au = a.upper() if(al == au): na = 0 bl = b.lower() bu = b.upper() if(bl == bu): nb = 0 cl = c.lower() cu = c.upper() if(cl == cu): nc = 0 dl = d.lower() du = d.upper() if(dl == du): nd = 0 arr = [[na,1],[nb,2],[nc,3],[nd,4]] arr.sort() gc = 0 if(((arr[0][0]*2) <= arr[1][0]) and ((arr[0][0]*2) <= arr[2][0]) and ((arr[0][0]*2) <= arr[3][0]) and (arr[0][0] != 0)): gc = arr[0][1] if((arr[3][0] >= (arr[0][0] * 2)) and (arr[3][0] >= (arr[1][0] * 2)) and (arr[3][0] >= (arr[2][0] * 2)) and (arr[3][0] != 0)): if(gc == 0): gc = arr[3][1] else: gc = 3 if(gc == 0): gc = 3 if(gc == 1): print("A") elif(gc == 2): print("B") elif(gc == 3): print("C") else: print("D")
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.io.*; import java.util.*; public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); try (PrintWriter out = new PrintWriter(outputStream)) { TaskA solver = new TaskA(); solver.solve(in, out); } } } class InputReader { public BufferedReader reader; public StringTokenizer tokenizer; public InputReader(InputStream inputstream) { reader = new BufferedReader(new InputStreamReader(inputstream)); tokenizer = null; } public String nextLine(){ String fullLine=null; while (tokenizer == null || !tokenizer.hasMoreTokens()) { try { fullLine=reader.readLine(); } catch (IOException e) { throw new RuntimeException(e); } return fullLine; } return fullLine; } public String next() { while (tokenizer == null || !tokenizer.hasMoreTokens()) { try { tokenizer = new StringTokenizer(reader.readLine()); } catch (IOException e) { throw new RuntimeException(e); } } return tokenizer.nextToken(); } public long nextLong() { return Long.parseLong(next()); } public int nextInt() { return Integer.parseInt(next()); } } class TaskA { void solve(InputReader in,PrintWriter out){ String a=in.next(); String b=in.next(); String c=in.next(); String d=in.next(); int index=-1; int count=0; int arr[]=new int[4]; arr[0]=a.length()-2; arr[1]=b.length()-2; arr[2]=c.length()-2; arr[3]=d.length()-2; for(int i=0;i<4;i++){ boolean flagA=true; boolean flagB=true; for(int j=0;j<4;j++){ if(i==j) continue; if(arr[i]*2>arr[j]){ flagA=false; } if(arr[i]<arr[j]*2){ flagB=false; } } if(flagA || flagB){ index=i; count++; } } if(count==1){ if(index==0) out.println("A"); if(index==1) out.println("B"); if(index==2) out.println("C"); if(index==3) out.println("D"); return; } out.println("C"); return; } }
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 str[4]; long long len[4]; while (cin >> str[0]) { len[0] = str[0].length() - 2; for (int i = 1; i < 4; i++) { cin >> str[i]; len[i] = str[i].length() - 2; } bool longer, shorter; long long great = 0, greati; for (int i = 0; i < 4; i++) { longer = shorter = true; for (int j = 0; j < 4; j++) { if (i == j) continue; if (len[i] < 2 * len[j]) longer = false; if (2 * len[i] > len[j]) shorter = false; } if (longer || shorter) { great++; greati = i; } } if (great == 1) cout << (char)('A' + greati) << 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
MC=['A', 'B', 'C', 'D'] lengths=[] for tc in xrange(4): lengths.append(len(raw_input())-2) lengths1=lengths[:] lengths.sort() if lengths[0]*2<=lengths[1] and lengths[2]*2>lengths[3]: print MC[lengths1.index(lengths[0])] elif lengths[2]*2<=lengths[3] and lengths[0]*2>lengths[1]: print MC[lengths1.index(lengths[-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
a = [len(input()[2:]), 'A'] b = [len(input()[2:]), 'B'] c = [len(input()[2:]), 'C'] d = [len(input()[2:]), 'D'] ans = None l = list(sorted([a, b, c, d])) if l[0][0] * 2 <= l[1][0] and l[2][0] * 2 > l[3][0]: ans = l[0][1] elif l[2][0] * 2 <= l[3][0] and l[0][0] * 2 > l[1][0]: ans = l[3][1] else: 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
#include <bits/stdc++.h> using namespace std; inline int getn() { register int n = 0, c = getchar(); while (c < '0' || c > '9') c = getchar(); while (c >= '0' && c <= '9') n = (n << 3) + (n << 1) + c - '0', c = getchar(); return n; } int prime[1000001]; bool ans[1000001]; vector<long long int> ans1; void seive() { prime[0] = 0; prime[1] = 0; long long int i, j; for (i = 2; i < 1000001; i++) { prime[i] = 1; } for (i = 2; i < 1000001; i++) { if (prime[i]) { ans1.push_back(i); for (j = i * i; j <= 1000000; j += i) { prime[j] = 0; } } } } int isprime(long int n) { long int i = 2; if (n == 1) return 0; for (i = 2; i <= sqrt(n); i++) { if (n % i == 0) return 0; } return 1; } int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a); } long long int gcdl(long long int a, long long int b) { if (a == 0) return b; return gcdl(b % a, a); } int ispalin(string str) { long long int i, j; i = 0; j = str.length() - 1; long long int n = str.length(); for (i = 0; i < n / 2; j--, i++) { if (str[i] != str[j]) return 0; } return 1; } long long int fact(int n) { long long int t = 1; while (n >= 1) { t = t * n; n--; } return t; } unsigned long long int myfunc(string str) { long long int p = 0; int i; for (i = 0; i < str.length(); i++) { p = p * 10 + (str[i] - 48); } return p; } unsigned long long int aayu(unsigned long long int x, unsigned long long int n, unsigned long long int mod1) { if (n == 0) return 1; if (n == 1) return x % mod1; if (n % 2 == 0) return (aayu((x * x) % mod1, n / 2, mod1)) % mod1; if (n % 2 == 1) return (x ^ mod1 * aayu((x * x) % mod1, (n - 1) / 2, mod1) % mod1); } void doseive() { for (int i = 6; i < 1000001; i++) { if (ans[i - 1] == 0) { ans[i] = 1; continue; } for (int j = 2; j <= sqrt(i); j++) { if (i % j == 0) { if (ans[j] == 0 || ans[i / j] == 0) { ans[i] = 1; break; } } } } } int main() { unsigned long long int i, j, n, flag = 0, t, x1, y1, p, l, r, m, way = 0, count = 0, x, y, index, ans2, ans, sum, pro, a, b, min, max, flag2 = 0, flag1 = 0, flag3 = 0, flag4 = 0, s, i1; string a1, b1, c1, d1; cin >> a1; cin >> b1; cin >> c1; cin >> d1; unsigned long long int len1, len2, len3, len4; len1 = a1.length() - 2; len2 = b1.length() - 2; len3 = c1.length() - 2; len4 = d1.length() - 2; if (((len1 * 2 <= len2) && (len1 * 2 <= len3) && (len1 * 2 <= len4)) || ((len1 >= 2 * len2) && (len1 >= 2 * len3) && (len1 >= 2 * len4))) { flag1 = 1; } if (((len2 * 2 <= len1) && (len2 * 2 <= len3) && (len2 * 2 <= len4)) || ((len2 >= 2 * len1) && (len2 >= 2 * len3) && (len2 >= 2 * len4))) { flag2 = 1; } if (((len3 * 2 <= len2) && (len3 * 2 <= len1) && (len3 * 2 <= len4)) || ((len3 >= 2 * len2) && (len3 >= 2 * len1) && (len3 >= 2 * len4))) { flag3 = 1; } if (((len4 * 2 <= len2) && (len4 * 2 <= len3) && (len4 * 2 <= len1)) || ((len4 >= 2 * len2) && (len4 >= 2 * len3) && (len4 >= 2 * len1))) { flag4 = 1; } if ((flag1) && (flag2 == 0) && (flag3 == 0) && (flag4 == 0)) { cout << 'A' << endl; return 0; } if ((flag1 == 0) && (flag2) && (flag3 == 0) && (flag4 == 0)) { cout << 'B' << endl; return 0; } if ((flag1 == 0) && (flag2 == 0) && (flag3) && (flag4 == 0)) { cout << 'C' << endl; return 0; } if ((flag1 == 0) && (flag2 == 0) && (flag3 == 0) && (flag4)) { cout << 'D' << endl; return 0; } 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
a = [] for i in range(4): t = raw_input() a.append(t) arr = [] for i in range(4): arr.append(((len(a[i])-2),i)) arr.sort() #print arr mif, mxf = 1,1 for i in range(1,4): if arr[i][0] < 2*arr[0][0]: mif = 0 for i in range(0,3): if 2*arr[i][0] > arr[3][0]: mxf = 0 def pr(i): #print i if i==0: print "A" if i==1: print "B" if i==2: print "C" if i==3: print "D" if mif==1 and mxf==0: pr(arr[0][1]) elif mxf==1 and mif==0: pr(arr[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 N = 10000; string v[5]; string ans = "ABCD"; int main() { for (int i = 0; i < 4; i++) { getline(cin, v[i]); v[i].erase(0, 2); } vector<int> v1; for (int i = 0; i < 4; i++) { bool flag = true; for (int j = 0; j < 4; j++) { if (i != j) { if (v[i].size() * 2 > v[j].size()) flag = false; } } if (flag) v1.push_back(i); } for (int i = 0; i < 4; i++) { bool flag = true; for (int j = 0; j < 4; j++) { if (i != j) { if (v[i].size() < 2 * v[j].size()) flag = false; } } if (flag) v1.push_back(i); } if (v1.size() == 1) { cout << ans[v1[0]]; } 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.BufferedInputStream; import java.util.Scanner; /** * Created by jizhe on 2015/12/18. */ public class TheChildAndHomework { public static void main(String[] args) { Scanner in = new Scanner(new BufferedInputStream(System.in)); int[] ls = new int[4]; int max = Integer.MIN_VALUE; int min = Integer.MAX_VALUE; int maxIndex = -1, minIndex = -1; for( int i = 0; i < 4; i++ ) { ls[i] = in.next().length()-2; if( ls[i] > max ) { max = ls[i]; maxIndex = i; } if( ls[i] < min ) { min = ls[i]; minIndex = i; } } //System.out.printf("max: %d, min: %d\n", maxIndex, minIndex); int count = 0; for( int i = 0; i < 4; i++ ) { if( i != minIndex && ls[i] < 2*min ) { //System.out.printf("ls: %d, min: %d\n", ls[i], min); minIndex = -1; } if( i != maxIndex && 2*ls[i] > max ) { //System.out.printf("ls: %d, max: %d\n", ls[i], max); maxIndex = -1; } } //System.out.printf("max: %d, min: %d\n", maxIndex, minIndex); if( (maxIndex == -1 && minIndex == -1) || (maxIndex != -1 && minIndex != -1) ) { System.out.printf("C\n"); return; } if( maxIndex != -1 ) { System.out.printf("%c\n", 'A'+maxIndex); return; } if( minIndex != -1 ) { System.out.printf("%c\n", 'A'+minIndex); return; } } }
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 st[] = new String[4]; int i,k = 0,flag,t = 0; int A[] = new int[4]; boolean B[] = new boolean[4]; Scanner s = new Scanner(System.in); for(i = 0;i < 4;i++){ st[i] = s.nextLine(); } for(i = 0;i < 4;i++){ A[i] = st[i].length()-2; } while(k < 4){ flag = 1; for(i = 0;i < 4;i++){ if(i != k && A[k] < 2*A[i]){ flag = 0; break; } } if(flag == 1){ B[k] = true; t++; } k++; } k = 0; while(k < 4){ flag = 1; for(i = 0;i < 4;i++){ if(i != k && 2*A[k] > A[i]){ flag = 0; break; } } if(flag == 1){ B[k] = true; t++; } k++; } if(B[2] || t == 0 || t > 1){ System.out.println("C"); }else{ if(B[0]){ System.out.println("A"); } else if(B[1]){ System.out.println("B"); } else{ 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
def main(): a = raw_input() b = raw_input() c = raw_input() d = raw_input() la = len(a) - 2 lb = len(b) - 2 lc = len(c) - 2 ld = len(d) - 2 lst = [(la, 'A'), (lb, 'B'), (lc,'C'), (ld,'D')] lst.sort() ans = 'C' ans1 = '' ans2 = '' if lst[0][0]*2 <= lst[1][0]: ans1 = lst[0][1] if lst[3][0] >= lst[2][0]*2: ans2 = lst[3][1] if((ans1 != '' and ans2 != '') or (ans1 == '' and ans2 == '')): print ans elif (ans1 == '' and ans2 != ''): print ans2 elif ans1 != '' and ans2 == '': print ans1 main()
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
from math import * from random import * a=[] for i in range(4): a.append(input()[2:]) ''' for i in range(4): print(a[i],len(a[i])) ''' g=[] for i in range(4): flag=1 flag1=1 for j in range(4): flag=flag and (i==j or len(a[i])>=2*len(a[j])) flag1=flag1 and (i==j or len(a[i])*2<=len(a[j])) if (flag or flag1): g.append(i) if len(g)==1: print(chr(g[0]+65)) exit() 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 = str(input()) b = str(input()) c = str(input()) d = str(input()) first = len(a) second = len(b) third = len(c) fourth = len(d) count1 = 0 count2 = 0 count3 = 0 count4 = 0 if(first - 2 >= 2 * (second - 2)): count1 += 1 if(first - 2 >= 2 * (third - 2)): count1 += 1 if(first - 2 >= 2 * (fourth - 2)): count1 += 1 if(2 * (first - 2) <= (second - 2)): count1 -= 1 if(2 * (first - 2) <= (third - 2)): count1 -= 1 if(2 * (first - 2) <= (fourth - 2)): count1 -= 1 if(second - 2 >= 2 * (first - 2)): count2 += 1 if(second - 2 >= 2 * (third - 2)): count2 += 1 if(second - 2 >= 2 * (fourth - 2)): count2 += 1 if(2 * (second - 2) <= (first - 2)): count2 -= 1 if(2 * (second - 2) <= (third - 2)): count2 -= 1 if(2 * (second - 2) <= (fourth - 2)): count2 -= 1 if(third - 2 >= 2 * (first - 2)): count3 += 1 if(third - 2 >= 2 * (second - 2)): count3 += 1 if(third - 2 >= 2 * (fourth - 2)): count3 += 1 if(2 * (third - 2) <= (first - 2)): count3 -= 1 if(2 * (third - 2) <= (second - 2)): count3 -= 1 if(2 * (third - 2) <= (fourth - 2)): count3 -= 1 if(fourth - 2 >= 2 * (first - 2)): count4 += 1 if(fourth - 2 >= 2 * (second - 2)): count4 += 1 if(fourth - 2 >= 2 * (third - 2)): count4 += 1 if(2 * (fourth - 2) <= (first - 2)): count4 -= 1 if(2 * (fourth - 2) <= (second - 2)): count4 -= 1 if(2 * (fourth - 2) <= (third - 2)): count4 -= 1 if((count1 == 3 or count1 == -3) and (count2 != 3 and count2 != -3) and (count3 != 3 and count3 != -3) and (count4 != 3 and count4 != -3)): print("A") elif((count1 != 3 and count1 != -3) and (count2 == 3 or count2 == -3) and (count3 != 3 and count3 != -3) and (count4 != 3 and count4 != -3)): print("B") elif((count1 != 3 and count1 != -3) and (count2 != 3 and count2 != -3) and (count3 == 3 or count3 == -3) and (count4 != 3 and count4 != -3)): print("C") elif((count1 != 3 and count1 != -3) and (count2 != 3 and count2 != -3) and (count3 != 3 or count3 != -3) and (count4 == 3 or count4 == -3)): 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
#include <bits/stdc++.h> using namespace std; struct stu { int len, id; } a[5]; int cmp(stu x, stu y) { return x.len > y.len; } int main() { char s[150], ans[5] = "ABCD"; for (int i = 0; i <= 3; i++) { scanf("%s", s); a[i].len = strlen(s) - 2; a[i].id = i; } sort(a, a + 4, cmp); bool flag1 = false, flag2 = false; if (a[0].len >= a[1].len * 2) flag1 = true; if (2 * a[3].len <= a[2].len) flag2 = true; if (flag1 && !flag2) printf("%c\n", ans[a[0].id]); else if (flag2 && !flag1) printf("%c\n", ans[a[3].id]); else printf("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
a = [len(raw_input())-2 for i in 'ABCD'] b = [i for i in xrange(4) if all(a[i]<=a[j]/2 for j in xrange(4) if j!=i) or all(a[i]>=a[j]*2 for j in xrange(4) if j!=i)] print 'ABCD'[b[0]] if len(b)==1 else '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() B = raw_input() C = raw_input() D = raw_input() strs = [A,B,C,D] good = [] for i in xrange(4): bad = False for j in xrange(4): if i != j: if 2 * (len(strs[i]) - 2) > len(strs[j]) - 2: bad = True break if not bad: good.append(i) for i in xrange(4): bad = False for j in xrange(4): if i != j: if (len(strs[i]) - 2) < 2 * (len(strs[j]) - 2): bad = True break if not bad: good.append(i) if len(good) == 1: print strs[good[0]][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; int main() { string s1, s2, s3, s4; cin >> s1 >> s2 >> s3 >> s4; int a[4] = {0, 0, 0, 0}; int l1 = s1.length() - 2; int l2 = s2.length() - 2; int l3 = s3.length() - 2; int l4 = s4.length() - 2; if (l1 >= 2 * l2 && l1 >= 2 * l3 && l1 >= 2 * l4) a[0]++; else if (2 * l1 <= l2 && 2 * l1 <= l3 && 2 * l1 <= l4) a[0]++; if (l2 >= 2 * l1 && l2 >= 2 * l3 && l2 >= 2 * l4) a[1]++; else if (2 * l2 <= l1 && 2 * l2 <= l3 && 2 * l2 <= l4) a[1]++; if (l4 >= 2 * l1 && l4 >= 2 * l2 && l4 >= 2 * l3) a[3]++; else if (2 * l4 <= l1 && 2 * l4 <= l2 && 2 * l4 <= l3) a[3]++; if (l3 >= 2 * l1 && l3 >= 2 * l2 && l3 >= 2 * l4) a[2]++; else if (2 * l3 <= l1 && 2 * l3 <= l2 && 2 * l3 <= l4) a[2]++; int count1 = 0; for (int i = 0; i < 4; i++) { if (a[i] == 1) count1++; } if (count1 != 1) cout << "C"; else { if (a[0] == 1) cout << "A"; else if (a[1] == 1) cout << "B"; else if (a[2] == 1) cout << "C"; else cout << "D"; } }
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
answerlist=[] lengthlist=[] great=0 finallist=['A','B','C','D'] for i in range(4): answerlist.append(str(input())) lengthlist.append(len(answerlist[i])-2) lengthlist1=lengthlist[:] lengthlist.sort() if lengthlist[0]*2<=lengthlist[1]: great=1 if lengthlist[3]>=lengthlist[2]*2: if great==1: great=0 else: great=2 if great==0: print('C') if great==1: print(finallist[lengthlist1.index(lengthlist[0])]) if great==2: print(finallist[lengthlist1.index(lengthlist[3])])
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.*; public class Main { public static void main(String[] args) { Scanner s = new Scanner (System.in); int A,B,C,D; A=s.next().length()-2; B=s.next().length()-2; C=s.next().length()-2; D=s.next().length()-2; int count=0; String S=""; if ((A>=B*2 && A>=C*2 && A>=D*2) || (A<=B/2 && A<=C/2 && A<=D/2) ) { count++; S="A"; } if ((B>=A*2 && B>=C*2 && B>=D*2) || (B<=A/2 && B<=C/2 && B<=D/2) ) { count++; S="B"; } if ((C>=A*2 && C>=B*2 && C>=D*2) || (C<=A/2 && C<=C/2 && C<=D/2) ) { count++; S="C"; } if ((D>=A*2 && D>=B*2 && D>=C*2) || (D<=A/2 && D<=B/2 && D<=C/2) ) { count++; S="D"; } if (count!=1) System.out.println("C"); else System.out.println(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
a = sorted([(len(input()[2::]), 'ABCD'[i]) for i in range(4)]) short = a[0][0] * 2 <= a[1][0] long = a[3][0] >= a[2][0] * 2 if short and long: print('C') elif short: print(a[0][1]) elif long: print(a[3][1]) 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=input() b=input() c=input() d=input() lst=[(len(a) - 2 ,"A"),(len(b) - 2,"B"),(len(c) - 2,"C"),(len(d) - 2,"D")] f1 = 0 f2 = 0 lst.sort(key=lambda x:x[0], reverse=True) if lst[0][0] >= 2 * lst[1][0]: f1 = 1 if lst[2][0] >= 2 * lst[3][0]: f2 = 1 if (f1 and f2) or (not f1 and not f2): print("C") elif f1: print(lst[0][1]) else: print(lst[3][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
a = len(input().split('.')[1]) b = len(input().split('.')[1]) c = len(input().split('.')[1]) d = len(input().split('.')[1]) arr = [a, b, c, d] one = False two = False for i in range(4): l = arr[i] c1 = c2 = 0 for j in range(4): if i != j: if l <= arr[j]//2: c1 +=1 elif l >= arr[j]*2: c2 += 1 if c1 == 3: one = True ans = i elif c2 == 3: two = True ans = i if (one and not two) or (two and not one): if ans == 0: print('A') elif ans == 1: print('B') elif ans == 2: print('C') else: 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
import java.util.*; import java.io.*; public class Main implements Runnable { public void solve() throws IOException { String[] s = new String[4]; for(int i = 0; i < 4; i++){ String cur = nextToken(); s[i] = cur.substring(2); } int answer = 2; Set<Integer> ans = new TreeSet<>(); for(int i = 0; i < 4; i++){ boolean ok = true; for(int j = 0; j < 4; j++){ if(i != j && s[i].length() * 2 > s[j].length()) ok = false; } if(ok){ answer = i; ans.add(i); } ok = true; for(int j = 0; j < 4; j++){ if(i != j && s[i].length() < s[j].length() * 2) ok = false; } if(ok){ answer = i; ans.add(i); } } if(ans.size() != 1) answer = 2; System.out.println((char)(answer + 'A')); } //----------------------------------------------------------- public static void main(String[] args) { new Main().run(); } public void print1Int(int[] a){ for(int i = 0; i < a.length; i++) System.out.print(a[i] + " "); System.out.println(); } public void print2Int(int[][] a){ for(int i = 0; i < a.length; i++){ for(int j = 0; j < a[0].length; j++){ System.out.print(a[i][j] + " "); } System.out.println(); } } public void run() { try { in = new BufferedReader(new InputStreamReader(System.in)); tok = null; solve(); in.close(); } catch (IOException e) { System.exit(0); } } public String nextToken() throws IOException { while (tok == null || !tok.hasMoreTokens()) { tok = new StringTokenizer(in.readLine()); } return tok.nextToken(); } public int nextInt() throws IOException { return Integer.parseInt(nextToken()); } public long nextLong() throws IOException { return Long.parseLong(nextToken()); } public double nextDouble() throws IOException { return Double.parseDouble(nextToken()); } BufferedReader in; StringTokenizer tok; }
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
q, t = 0, sorted([(len(input()) - 2, i) for i in 'ABCD']) if 2 * t[0][0] <= t[1][0]: q += 1 if t[3][0] >= 2 * t[2][0]: q += 2 print(['C', t[0][1], t[3][1], 'C'][q])
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.*; public class Main { public static void main(String[] args) { Scanner cin=new Scanner(System.in); String[] xuan=new String[4]; for(int i=0;i<4;i++) xuan[i]=cin.nextLine(); StringBuilder ans=new StringBuilder(); for(int i=0;i<4;i++) { int goal=xuan[i].length()-2; int flag1=0,flag2=0; for(int j=0;j<4;j++) { if(i==j) continue; int temp=xuan[j].length()-2; // System.out.println(i+" , "+j+" , "+goal+" , "+temp); if(goal*2<=temp) flag1++; if(temp*2<=goal) flag2++; } // System.out.println("flag1: "+flag1+" flag2: "+flag2); if(flag1==3||flag2==3) ans.append((char)(i+'A')); } //System.out.println("---> "+ans); if(ans.length()==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
import java.io.*; import java.util.*; 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); Task solver = new Task(); solver.solve(in, out); out.close(); } static class Task { public void solve(InputReader in, PrintWriter out) { String[] s = new String[4]; for (int i = 0; i < 4; i++) { s[i] = in.next(); } ArrayList<Integer> great = new ArrayList<>(); for (int i = 0; i < 4; i++) { int cnt1 = 0, cnt2 = 0; for (int j = 0; j < 4; j++) { if ((s[i].length() - 2) * 2 <= s[j].length() - 2) { cnt1++; } if (s[i].length() - 2 >= 2 * (s[j].length() - 2)) { cnt2++; } } if (cnt1 == 3 || cnt2 == 3) { great.add(i); } } if (great.size() == 1) { out.println((char)(great.get(0) + 'A')); } 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 next() { while (tokenizer == null || !tokenizer.hasMoreTokens()) { try { tokenizer = new StringTokenizer(reader.readLine()); } catch (IOException e) { throw new RuntimeException(e); } } return tokenizer.nextToken(); } public int nextInt() { return Integer.parseInt(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
#include <bits/stdc++.h> using namespace std; const double eps = 1e-9; const double pi = acos(-1.0); pair<int, char> a[4]; int main() { for (int i = 0; i < 4; ++i) { string second; cin >> second; a[i] = make_pair(int((second).size()) - 2, char('A' + i)); } sort(a, a + 4); if (a[3].first >= a[2].first * 2) { if (a[0].first * 2 <= a[1].first) { putchar('C'); } else cout << a[3].second; } else if (a[0].first * 2 <= a[1].first) { cout << a[0].second; } else putchar('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
//package ff; import java.util.Scanner; public class prba { public static void main(String[] args) { Scanner sc = new Scanner(System.in); // int n = sc.nextInt(); String[] arr = new String[4]; boolean q = true; String out = ""; for (int i = 0; i < 4; i++) arr[i] = sc.next(); for (int i = 0; i < 4; i++) { int tt = arr[i].length()-2; q = check(tt, i, arr); if (q) out += (arr[i].charAt(0) + ""); } if (out.length() > 1 || out.length() == 0) System.out.println("C"); else System.out.println(out.charAt(0)); } public static boolean check(int n, int x, String[] a) { String w = null; ; boolean flag = true; boolean flag2 = true; for (int i = 0; i < 4; i++) { int k = a[i].length(); k-=2; w = a[i].charAt(0) + ""; if (i != x) { if (flag) if (!((k / 2) >= n)) flag = false; if (flag2){ //System.out.println(n); //System.out.println(k*2); if (!((k*2) <= (n))) flag2 = false; } } } // System.out.println(flag?"flag":flag2?"flag2":"bom"); if (flag || flag2) return true; else return false; } }
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; char question[4][100]; int len[4]; int main() { for (int i = 0; i < 4; i++) { cin >> question[i]; string s = question[i]; len[i] = s.size() - 2; } int count_ = 0; int index = -1; for (int i = 0; i < 4; i++) { int n; n = len[0]; len[0] = len[i]; len[i] = n; if (((len[0] <= (len[1] / 2)) && (len[0] <= (len[2] / 2)) && (len[0] <= (len[3] / 2))) || ((len[0] >= (2 * len[1])) && (len[0] >= (2 * len[2])) && (len[0] >= (2 * len[3])))) { index = i; count_++; } } if (count_ == 1) { cout << (char)(index + 65); } 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.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; public class Main { static class FastScanner{ BufferedReader s; StringTokenizer st; public FastScanner(){ st = new StringTokenizer(""); s = new BufferedReader(new InputStreamReader(System.in)); } public FastScanner(File f) throws FileNotFoundException{ st = new StringTokenizer(""); s = new BufferedReader (new FileReader(f)); } public int nextInt() throws IOException{ if(st.hasMoreTokens()) return Integer.parseInt(st.nextToken()); else{ st = new StringTokenizer(s.readLine()); return nextInt(); } } public double nextDouble() throws IOException{ if(st.hasMoreTokens()) return Double.parseDouble(st.nextToken()); else{ st = new StringTokenizer(s.readLine()); return nextDouble(); } } public long nextLong() throws IOException{ if(st.hasMoreTokens()) return Long.parseLong(st.nextToken()); else{ st = new StringTokenizer(s.readLine()); return nextLong(); } } public String nextString() throws IOException{ if(st.hasMoreTokens()) return st.nextToken(); else{ st = new StringTokenizer(s.readLine()); return nextString(); } } public String readLine() throws IOException{ return s.readLine(); } public void close() throws IOException{ s.close(); } } private static FastScanner s = new FastScanner(); private static PrintWriter ww = new PrintWriter(new OutputStreamWriter(System.out)); static int count=0; public static void main(String[] args) throws IOException { String[] q= new String[4]; q[0]=s.nextString(); int a=q[0].length()-2; q[1]=s.nextString(); int b=q[1].length()-2; q[2]=s.nextString(); int c=q[2].length()-2; q[3]=s.nextString(); int d=q[3].length()-2; // ww.println(" a "+a+" b "+b+" c "+c+" d "+d); int e=0,f=0,g=0,h=0; if((a<=(b/2)&&a<=(c/2)&&a<=(d/2))||(a>=(2*b)&&a>=(2*c)&&a>=(2*d))) e=1; if((b<=(a/2)&&b<=(c/2)&&b<=(d/2))||(b>=(2*a)&&b>=(2*c)&&b>=(2*d))) f=1; if((c<=(a/2)&&c<=(b/2)&&c<=(d/2))||(c>=(2*b)&&c>=(2*a)&&c>=(2*d))) g=1; if((d<=(b/2)&&d<=(c/2)&&d<=(a/2))||(d>=(2*b)&&d>=(2*c)&&d>=(2*a))) h=1; if((e==1)&&(f==0&&g==0&&h==0)) ww.println("A"); else if((f==1)&&(e==0&&g==0&&h==0)) ww.println("B"); else if((g==1)&&(f==0&&e==0&&h==0)) ww.println("C"); else if((h==1)&&(f==0&&g==0&&e==0)) ww.println("D"); else ww.println("C"); s.close(); ww.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.*; public class Main { public static void main(String[] args) { Scanner cin=new Scanner(System.in); String[] xuan=new String[4]; for(int i=0;i<4;i++) xuan[i]=cin.nextLine(); StringBuilder ans=new StringBuilder(); for(int i=0;i<4;i++) { int goal=xuan[i].length()-2; int flag1=0,flag2=0; for(int j=0;j<4;j++) { if(i==j) continue; int temp=xuan[j].length()-2; if(goal*2<=temp) flag1++; if(temp*2<=goal) flag2++; } if(flag1==3||flag2==3) ans.append((char)(i+'A')); } if(ans.length()==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
#include <bits/stdc++.h> using namespace std; int main() { string a, b, c, d; bool has_min = false, has_max = false; int arr[4], a1, b1, c1, d1; cin >> a >> b >> c >> d; arr[0] = a.size() - 2; arr[1] = b.size() - 2; arr[2] = c.size() - 2; arr[3] = d.size() - 2; a1 = arr[0]; b1 = arr[1]; c1 = arr[2]; d1 = arr[3]; sort(arr, arr + 4); if (arr[0] <= arr[1] / 2) has_min = true; if (arr[3] >= 2 * arr[2]) has_max = true; if (has_max == true && has_min == true) cout << "C" << endl; else { if (a1 >= 2 * b1 && a1 >= 2 * c1 && a1 >= 2 * d1 || a1 <= b1 / 2 && a1 <= c1 / 2 && a1 <= d1 / 2) cout << "A" << endl; else if (b1 >= 2 * a1 && b1 >= 2 * c1 && b1 >= 2 * d1 || b1 <= a1 / 2 && b1 <= c1 / 2 && b1 <= d1 / 2) cout << "B" << endl; else if (c1 >= 2 * a1 && c1 >= 2 * b1 && c1 >= 2 * d1 || c1 <= a1 / 2 && c1 <= b1 / 2 && c1 <= d1 / 2) cout << "C" << endl; else if (d1 >= 2 * a1 && d1 >= 2 * b1 && d1 >= 2 * c1 || d1 <= a1 / 2 && d1 <= b1 / 2 && d1 <= c1 / 2) 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
#include <bits/stdc++.h> using namespace std; long long int solve() { string a, b, c, d; cin >> a >> b >> c >> d; long long int l[4]; l[0] = a.size() - 2; l[1] = b.size() - 2; l[2] = c.size() - 2; l[3] = d.size() - 2; long long int f = 0; char s; if ((2 * l[0] <= l[1] && 2 * l[0] <= l[2] && 2 * l[0] <= l[3]) || (l[0] >= 2 * l[1] && l[0] >= 2 * l[2] && l[0] >= 2 * l[3])) f++, s = 'a'; if ((2 * l[1] <= l[0] && 2 * l[1] <= l[2] && 2 * l[1] <= l[3]) || (l[1] >= 2 * l[0] && l[1] >= 2 * l[2] && l[1] >= 2 * l[3])) f++, s = 'b'; if ((2 * l[3] <= l[1] && 2 * l[3] <= l[2] && 2 * l[3] <= l[0]) || (l[3] >= 2 * l[1] && l[3] >= 2 * l[2] && l[3] >= 2 * l[0])) f++, s = 'd'; if ((2 * l[2] <= l[1] && 2 * l[2] <= l[3] && 2 * l[2] <= l[0]) || (l[2] >= 2 * l[1] && l[2] >= 2 * l[3] && l[2] >= 2 * l[0])) f++, s = 'c'; if (f == 1) cout << (char)(s - 32); else cout << "C"; return 0; } signed main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long int tests = 1; while (tests--) solve(); 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
p=[] for i in range(4): p.append(len(str(input("")))) l={"A":(p[0])-2,"B":(p[1])-2,"C":(p[2])-2,"D":(p[3])-2} p=sorted(l.items() , key= lambda x:x[1]) if(2*p[0][1]<=p[1][1] and p[-1][1]>=p[-2][1]*2): print("C") elif(2*p[0][1]<=p[1][1]): print(p[0][0]) elif(p[-1][1]>=p[-2][1]*2): print(p[-1][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; char c[5] = {'5', 'A', 'B', 'C', 'D'}; int main() { string str[5]; while (cin >> str[1] >> str[2] >> str[3] >> str[4]) { int cnt = 0; int ans; for (int i = 1; i <= 4; ++i) { int flag = 1; for (int j = 1; j <= 4; ++j) { if (i == j) continue; if ((str[i].length() - 2) / (str[j].length() - 2) < 2) flag = 0; } if (flag) { cnt++; ans = i; } } for (int i = 1; i <= 4; ++i) { int flag = 1; for (int j = 1; j <= 4; ++j) { if (i == j) continue; if ((str[j].length() - 2) / (str[i].length() - 2) < 2) flag = 0; } if (flag) { cnt++; ans = i; } } if (cnt > 1 || cnt == 0) cout << "C" << endl; else cout << c[ans] << 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; vector<pair<int, char> > yara; string x; bool WE, LOVE = false; int main() { for (int i = 0; i < 4; i++) { cin >> x; yara.push_back(make_pair(x.size() - 2, x[0])); } sort(yara.begin(), yara.end()); if (2 * yara[0].first <= yara[1].first) { WE = true; } if (yara[3].first >= yara[2].first * 2) { LOVE = true; } if (WE && LOVE) cout << "C\n"; else if (!WE && !LOVE) cout << "C\n"; else if (LOVE) { cout << yara[3].second << endl; } else cout << yara[0].second << 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() { ios::sync_with_stdio(0); cin.tie(0); vector<string> A(4); for (int i = 0; i < 4; i++) { cin >> A[i]; A[i] = A[i].substr(2); } vector<int> B; for (int i = 0; i < 4; i++) { bool flag1 = true, flag2 = true; for (int j = 0; j < 4; j++) { if (i == j) continue; if (A[i].size() < A[j].size() * 2) flag1 = false; } for (int j = 0; j < 4; j++) { if (i == j) continue; if (A[i].size() * 2 > A[j].size()) flag2 = false; } if (flag1 || flag2) B.push_back(i); } if (B.size() == 1) cout << (char)('A' + B[0]) << endl; 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
def main(): 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) greatChoices = [] for i in range(len(lines)): condition1 = True condition2 = True for j in range(len(lines)): if i != j: condition1 = condition1 and 2 * lengths[i] <= lengths[j] condition2 = condition2 and 2 * lengths[j] <= lengths[i] if condition1 or condition2: greatChoices.append(CHOICES[i]) if len(greatChoices) == 1: print(greatChoices[0]) else: print('C') main()
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() arr1 = [A,B,C,D] arr = [] k=1 w=0 arr.append(len(A)-2) arr.append(len(B)-2) arr.append(len(C)-2) arr.append(len(D)-2) for i in range(4): a=0 b=0 for j in range(4): if i!=j and arr[i]<=int(arr[j]/2): a=a+1 if i!=j and arr[i]>=2*arr[j]: b = b+1 if(a==3 or b==3): w=w+1 l=i if(w==1): print(arr1[l][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
s1=raw_input().split('.') s2=raw_input().split('.') s3=raw_input().split('.') s4=raw_input().split('.') l1=len(s1[1]) l2=len(s2[1]) l3=len(s3[1]) l4=len(s4[1]) c=[] if l1>=l2*2 and l1>=l3*2 and l1>=l4*2 or l1<=l2/2 and l1<=l3/2 and l1<=l4/2: c.append('A') if l2>=l1*2 and l2>=l3*2 and l2>=l4*2 or l2<=l1/2 and l2<=l3/2 and l2<=l4/2: c.append('B') if l3>=l2*2 and l3>=l1*2 and l3>=l4*2 or l3<=l2/2 and l3<=l1/2 and l3<=l4/2: c.append('C') if l4>=l2*2 and l4>=l3*2 and l4>=l1*2 or l4<=l2/2 and l4<=l3/2 and l4<=l1/2: c.append('D') if len(c) > 1 or len(c)==0: print 'C' else: print c[0]
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
#!/usr/bin/env python def pri(i): if i == 0: print "A" if i == 1: print "B" if i == 2: print "C" if i == 3: print "D" if __name__ == "__main__": lA = raw_input() lB = raw_input() lC = raw_input() lD = raw_input() a = [len(lA.split(".")[1]), len(lB.split(".")[1]), len(lC.split(".")[1]), len(lD.split(".")[1])] great = 0 choice =[] m = min(a) for i in a: if i/m >= 2: great=great+1 if great == 3: choice.append(m) #print "great, len choice, m", great, len(choice), m m = max(a) great = 0 for i in a: if m/i >= 2: great=great+1 if great == 3: choice.append(m) #print "great, len choice, m", great, len(choice), m if great == 3 and len(choice)==1: pri(a.index(m)) else: if len(choice)==1: pri(a.index(min(a))) else: pri(2)
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.InputStreamReader; import java.io.IOException; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.math.BigInteger; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * @author shu_mj @ http://shu-mj.com */ public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; Scanner in = new Scanner(inputStream); PrintWriter out = new PrintWriter(outputStream); TaskA solver = new TaskA(); solver.solve(1, in, out); out.close(); } } class TaskA { public void solve(int testNumber, Scanner in, PrintWriter out) { int[] is = new int[4]; for (int i = 0; i < 4; i++) { is[i] = in.next().length() - 2; } boolean f = false; int ans = 0; for (int i = 0; i < 4; i++) { if (fit(is, i)) { ans = i; if (f) {out.println('C'); return ;} f = true; } } // 这是一个中文注释 if (f) out.println((char)('A' + ans)); else out.println('C'); } private boolean fit(int[] is, int i) { int less = 0, great = 0; for (int j = 0; j < 4; j++) { if (i != j) { if (is[j] * 2 <= is[i]) less++; if (is[j] >= is[i] * 2) great++; } } return less == 3 || great == 3; } } class Scanner { BufferedReader br; StringTokenizer st; public Scanner(InputStream in) { br = new BufferedReader(new InputStreamReader(in)); eat(""); } private void eat(String s) { st = new StringTokenizer(s); } public String nextLine() { try { return br.readLine(); } catch (IOException e) { return null; } } public boolean hasNext() { while (!st.hasMoreTokens()) { String s = nextLine(); if (s == null) return false; eat(s); } return true; } public String next() { hasNext(); 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
ans=[] for i in range (4): ans.append(raw_input().split('.')) great=[] a,b,c,d=len(ans[0][1]),len(ans[1][1]),len(ans[2][1]),len(ans[3][1]) if 2*a<=min(b,c,d) or a>=2*max(b,c,d): great.append('A') if 2*b<=min(a,c,d) or b>=2*max(a,c,d): great.append('B') if 2*c<=min(b,a,d) or c>=2*max(b,a,d): great.append('C') if 2*d<=min(b,a,c) or d>=2*max(b,a,c): great.append('D') if len(great)==1: print great[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
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] dic={'A':l[0],'B':l[1],'C':l[2],'D':l[3]} l = sorted(l) big=0 small=0 count=0 #print l if l[3]>=l[2]*2: count+=1 big=1 if 2*l[0]<=l[1]: count+=1 small=1 if count==1: if big==1: print max(dic.iterkeys(),key=lambda k:dic[k]) if small==1: print min(dic.iterkeys(),key=lambda k:dic[k]) 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 itertools import sys from collections import defaultdict, Counter from math import sqrt input = sys.stdin.readline ############ ---- Input Functions ---- ############ def inp(): return (int(input())) def inlt(): return (list(map(int, input().split()))) def insr(): s = input() return (list(s[:len(s) - 1])) def invr(): return (map(int, input().split())) def s(d): dis = 1 + 4 * 2 * 3 * d ds = sqrt(dis) return (-1 + ds) / 6 def main(): d = [len(input().strip())-2 for _ in range(4)] res = [] for i,v in enumerate(d): c1 = [v*2<=v2 for j,v2 in enumerate(d) if i!=j] c2 = [v >= v2*2 for j, v2 in enumerate(d) if i != j] if all(c1) or all(c2): res.append(i) if len(res) == 1: print(chr(ord('A') + res[0])) else: print('C') if __name__ == "__main__": # sys.setrecursionlimit(10 ** 6) # threading.stack_size(10 ** 8) # t = threading.Thread(target=main) # t.start() # t.join() 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
def STR(): return list(input()) def INT(): return int(input()) def MAP(): return map(int, input().split()) def MAP2():return map(float,input().split()) def LIST(): return list(map(int, input().split())) def STRING(): return input() import string import sys from heapq import heappop , heappush from bisect import * from collections import deque , Counter , defaultdict from math import * from itertools import permutations , accumulate dx = [-1 , 1 , 0 , 0 ] dy = [0 , 0 , 1 , - 1] #visited = [[False for i in range(m)] for j in range(n)] #sys.stdin = open(r'input.txt' , 'r') #sys.stdout = open(r'output.txt' , 'w') #for tt in range(INT()): #Code def check1(l): r = 0 m = [] for i in range(4): c = 0 for j in range(4): if (i != j): if (l[j] >= 2 * l[i]): c +=1 if (c == 3): r +=1 m.append(i) if r == 1 : return m else: return -1 def check2(l): r = 0 m = [] for i in range(4): c = 0 for j in range(4): if (i != j): if (2 * l[j] <= l[i]): c +=1 if (c == 3): r +=1 m.append(i) if r == 1: return m else: return -1 v = [] for i in range(4): x = STRING() x = x[2:] v.append(len(x)) k1 = check1(v) k2 = check2(v) flag = ['A' , 'B' , 'C' , 'D'] if (k1 != -1 and k2 == -1 ): print(flag[k1[0]]) elif (k1 ==-1 and k2 != -1 ): print(flag[k2[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; struct predicate { bool operator()(const pair<char, int> &left, const pair<char, int> &right) { return left.second < right.second; } }; int main() { string s1, s2, s3, s4; vector<pair<char, int>> v; bool x = false; double size1, size2, size3, size4, res0, res1, great = 0; cin >> s1 >> s2 >> s3 >> s4; v.push_back(make_pair('A', s1.size() - 2)); v.push_back(make_pair('B', s2.size() - 2)); v.push_back(make_pair('C', s3.size() - 2)); v.push_back(make_pair('D', s4.size() - 2)); sort(v.begin(), v.end(), predicate()); res0 = 2 * v[0].second; res1 = v[3].second / 2; if (res0 <= v[1].second && res0 <= v[2].second && res0 <= v[3].second) { great++; x = true; } if (res1 >= v[0].second && res1 >= v[1].second && res1 >= v[2].second) { great++; } if (great > 1 || great == 0) { cout << "C" << endl; } else { if (x == true) { cout << v[0].first << endl; } else { cout << v[3].first << 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; string a, b, c, d; int len[5], ans; bool check(int x) { int flag1 = 1, flag2 = 1; for (int i = 1; i <= 4; i++) if (i != x && len[x] < len[i] * 2) flag1 = 0; for (int i = 1; i <= 4; i++) if (i != x && len[x] > len[i] / 2) flag2 = 0; return flag1 | flag2; } int main() { cin >> a >> b >> c >> d; len[1] = a.size() - 2; len[2] = b.size() - 2; len[3] = c.size() - 2; len[4] = d.size() - 2; for (int i = 1; i <= 4; i++) { if (check(i)) { if (!ans) ans = i; else ans = 5; } } if (ans == 1) cout << "A"; else if (ans == 2) cout << "B"; else if (ans == 4) 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
a = sorted([(len(input())-2,i) for i in 'ABCD']) g = "" if a[0][0]*2 <= a[1][0]: g += a[0][1] if a[3][0] >= 2 * a[2][0]: g += a[3][1] if len(g) == 1: print(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.io.*; import java.util.*; import java.math.*; public class p437a { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int[] a = new int[4]; int[] b = new int[4]; String[] str = new String[4]; int check = -1; for (int i = 0; i < 4; ++i) { str[i] = sc.next(); a[i] = str[i].length() - 2; b[i] = a[i]; } Arrays.sort(a); int best = -1; if (a[0] * 2 <= a[1]) { check = a[0]; } if (a[2] * 2 <= a[3]) { if (check == -1) { check = a[3]; } else { check = -1; } } if (check == -1) { System.out.println("C"); } else { for (int i = 0; i < 4; ++i) { if (b[i] == check) { System.out.println((char)('A' + i)); } } } } }
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(): l = [] c = [] for i in range(4): l.append(input()[2:]) c.append(len(l[-1])) g = [False] * 4 for i in range(4): longer = 0 shorter = 0 for j in range(4): if i == j: continue if c[i] <= c[j] // 2: shorter += 1 if c[i] >= c[j] * 2: longer += 1 g[i] = (longer == 3) | (shorter == 3) if len(list(filter(lambda i: i, g))) > 1: return 'C' for i in range(4): if g[i]: return ['A', 'B', 'C', 'D'][i] return "C" print(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
import java.io.*; import java.lang.*; import java.util.*; public class Main { public static void main(String[] args) throws IOException { InputReader reader = new InputReader(System.in); PrintWriter writer = new PrintWriter(System.out, true); try { Task task = new Task(); task.solve(reader, writer); } finally { reader.close(); writer.close(); } } } class Task { public void solve(InputReader reader, PrintWriter writer) throws IOException { int[] ls = new int[4]; for (int i =0 ;i < 4; i++) { String a = reader.nextToken(); ls[i] = a.length() - 2; } int answer = -1; for (int i =0; i < 4; i++) { boolean isLowest = true; boolean isBiggest = true; for (int j=0; j<4; j++) { if (i == j) {continue;} if (ls[j] / 2 < ls[i]) { isLowest = false; } if (ls[i] / 2 < ls[j]) { isBiggest = false; } } if (isLowest || isBiggest) { if (-1 != answer) { writer.println('C'); return; } answer = i + 'A'; } } if (-1 == answer) { writer.println('C'); } else { writer.println((char) answer); } } } class InputReader { private StringTokenizer tokenizer; private BufferedReader reader; InputReader(InputStream stream) { this.reader = new BufferedReader(new InputStreamReader(stream)); } public String nextToken() throws IOException { while (null == tokenizer || !tokenizer.hasMoreTokens()) { this.tokenizer = new StringTokenizer(reader.readLine()); } return this.tokenizer.nextToken(); } public int nextInt() throws IOException { return Integer.parseInt(nextToken()); } public void close() throws IOException{ this.reader.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; string ss[] = {"A", "B", "C", "D"}; int main() { ios_base::sync_with_stdio(0); string s[4]; cin >> s[0]; cin >> s[1]; cin >> s[2]; cin >> s[3]; int a[4]; int b[4]; a[0] = s[0].length() - 2; a[1] = s[1].length() - 2; a[2] = s[2].length() - 2; a[3] = s[3].length() - 2; b[0] = a[0], b[1] = a[1], b[2] = a[2], b[3] = a[3]; sort(a, a + 4); if (2 * a[0] <= a[1]) { if (a[3] >= 2 * a[2]) cout << ss[2] << endl; else { for (int i = 0; i < 4; i++) { if (a[0] == b[i]) cout << ss[i] << endl; } } } else { if (a[3] >= 2 * a[2]) { for (int i = 0; i < 4; i++) { if (a[3] == b[i]) cout << ss[i] << endl; } } else cout << ss[2] << 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
''' Created on 2016年3月4日 @author: HaoGe ''' choise=[] for i in range(4): ci=input() choise.append( [ len(ci)-2, ci[0] ] ) choise.sort() if 2*choise[0][0]<=choise[1][0] and choise[3][0]<2*choise[2][0]: print(choise[0][1]) elif choise[3][0]>=2*choise[2][0] and 2*choise[0][0]>choise[1][0]: print(choise[3][1]) 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 operator def main(): h = {} for x in range(4): input = raw_input() h[input] = len(input.split('.')[1]) sort = sorted(h.iteritems(), key=operator.itemgetter(1)) count = 0 ans = None if sort[0][1]*2 <= sort[1][1]: count += 1 ans = sort[0][0].split('.')[0] if sort[3][1]/2 >= sort[2][1]: count += 1 ans = sort[3][0].split('.')[0] if count == 1: print ans.upper() else: print 'C' if __name__ == "__main__": main()
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 main(): l = [] for _ in range(4): n, s = input().split('.') l.append((len(s), n)) a, b, c, d = sorted(l) res = ['C'] if a[0] * 2 <= b[0]: res.append(a[1]) if c[0] * 2 <= d[0]: res.append(d[1]) print(res[(len(res) - 1) & 1]) 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
s = [] length = [0 for i in range(4)] for i in range(4): s.append(input()[2:]) length[i] = len(s[i]) var = [] for i in range(4): if length[i] >= 2*max(length[:i] + length[i+1:]) or \ length[i] <= min(length[:i] + length[i+1:])//2: var.append(i) if len(var) == 1: print(chr(ord('A') + var[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
Q = [("A", raw_input()[2:]), ("B", raw_input()[2:]), ("C", raw_input()[2:]), ("D", raw_input()[2:])] nQ = [n[1] for n in Q] great = [] for id, n in Q: ln = len(n) for _, z in Q: if z != n: # Twice shorter if len(z) / ln >= 2: pass else: break else: if nQ.count(n) == 1: great.append(id) for id, n in Q: ln = len(n) for _, z in Q: if z != n: # Twice longer if ln / len(z) >= 2: pass else: break else: if nQ.count(n) == 1: great.append(id) if len(great) == 1: print great[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
l1=list(str(input())) l2=list(str(input())) l3=list(str(input())) l4=list(str(input())) c=[] if (len(l1)-2>=(2*(len(l2)-2)) and len(l1)-2>=(2*(len(l3)-2)) and len(l1)-2>=(2*(len(l4)-2))) or (len(l2)-2>=(2*(len(l1)-2)) and len(l3)-2>=(2*(len(l1)-2)) and len(l4)-2>=(2*(len(l1)-2))): c.append(1) else: c.append(0) if (len(l2)-2>=(2*(len(l1)-2)) and len(l2)-2>=(2*(len(l3)-2)) and len(l2)-2>=(2*(len(l4)-2))) or (len(l1)-2>=(2*(len(l2)-2)) and len(l3)-2>=(2*(len(l2)-2)) and len(l4)-2>=(2*(len(l2)-2))): c.append(1) else: c.append(0) if (len(l3)-2>=(2*(len(l2)-2)) and len(l3)-2>=(2*(len(l1)-2)) and len(l3)-2>=(2*(len(l4)-2))) or (len(l2)-2>=(2*(len(l3)-2)) and len(l1)-2>=(2*(len(l3)-2)) and len(l4)-2>=(2*(len(l3)-2))): c.append(1) else: c.append(0) if (len(l4)-2>=(2*(len(l2)-2)) and len(l4)-2>=(2*(len(l3)-2)) and len(l4)-2>=(2*(len(l1)-2))) or (len(l2)-2>=(2*(len(l4)-2)) and len(l3)-2>=(2*(len(l4)-2)) and len(l1)-2>=(2*(len(l4)-2))): c.append(1) else: c.append(0) d={0:"A",1:"B",2:"C",3:"D"} if c.count(1)>1 or c.count(1)==0: print("C") else: for j in range(4): if c[j]==1: print(d[j])
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.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; public class Main { public static void main(String args[]) throws NumberFormatException,IOException { Stdin in = new Stdin(); PrintWriter out = new PrintWriter(System.out); int a=in.readNext().length()-2; int b=in.readNext().length()-2; int c=in.readNext().length()-2; int d=in.readNext().length()-2; char[]ans={' ',' ',' ',' '}; int count=0; if(valid(a,b,c,d)){ ans[0]='A'; count++; } if(valid(b,a,c,d)){ ans[1]='B'; count++; } if(valid(c,a,b,d)){ ans[2]='C'; count++; } if(valid(d,a,b,c)){ ans[3]='D'; count++; } if(count!=1) out.println('C'); else{ for(char c1:ans){ if(c1!=' '){ out.println(c1); break; } } } out.flush(); out.close(); } public static boolean valid(int a,int b,int c,int d){ if(2*a<=b&&2*a<=c&&2*a<=d) return true; if(a>=2*b&&a>=2*c&&a>=2*d) return true; return false; } private static class Stdin { InputStreamReader read; BufferedReader br; StringTokenizer st = new StringTokenizer(""); private Stdin() { read = new InputStreamReader(System.in); br = new BufferedReader(read); } private String readNext() throws IOException { while (!st.hasMoreTokens()) st = new StringTokenizer(br.readLine()); return st.nextToken(); } private int readInt() throws IOException, NumberFormatException { return Integer.parseInt(readNext()); } private long readLong() throws IOException, NumberFormatException { return Long.parseLong(readNext()); } } }
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
lis=[] for i in range(4): lis.append(len(input())-2) pos=[] if (lis[1]//lis[0]>=2 and lis[2]//lis[0]>=2 and lis[3]//lis[0]>=2) or \ (lis[0]//lis[1]>=2 and lis[0]//lis[2]>=2 and lis[0]//lis[3]>=2): pos.append('A') if (lis[0]//lis[1]>=2 and lis[2]//lis[1]>=2 and lis[3]//lis[1]>=2) or \ (lis[1]//lis[0]>=2 and lis[1]//lis[2]>=2 and lis[1]//lis[3]>=2): pos.append('B') if (lis[1]//lis[2]>=2 and lis[0]//lis[2]>=2 and lis[3]//lis[2]>=2) or \ (lis[2]//lis[1]>=2 and lis[2]//lis[0]>=2 and lis[2]//lis[3]>=2): pos.append('C') if (lis[1]//lis[3]>=2 and lis[2]//lis[3]>=2 and lis[0]//lis[3]>=2) or \ (lis[3]//lis[1]>=2 and lis[3]//lis[2]>=2 and lis[3]//lis[0]>=2): pos.append('D') if len(pos)==1: print(pos[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; bool compare(pair<string, long long> p, pair<string, long long> q) { return p.second > q.second; } bool mcompare(pair<string, long long> p, pair<string, long long> q) { return p.second < q.second; } int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); string c1, c2, c3, c4; cin >> c1 >> c2 >> c3 >> c4; vector<pair<string, long long>> v; v.push_back({c1, c1.length() - 2}); v.push_back({c2, c2.length() - 2}); v.push_back({c3, c3.length() - 2}); v.push_back({c4, c4.length() - 2}); sort(v.begin(), v.end(), compare); long long max = v[0].second; long long count = 0; for (long long i = 0; i < v.size(); i++) { if (v[i].second == max) count++; } string ans = "C"; long long grc = 0; if (count == 1 && v[0].second >= v[1].second * 2) { if (v[0].first == c1) ans = "A"; else if (v[0].first == c2) ans = "B"; else if (v[0].first == c3) ans = "C"; else ans = "D"; grc++; } long long cnt = 0; sort(v.begin(), v.end(), mcompare); long long min = v[0].second; for (long long i = 0; i < v.size(); i++) if (v[i].second == min) cnt++; if (cnt == 1 && v[0].second * 2 <= v[1].second) { if (v[0].first == c1) ans = "A"; else if (v[0].first == c2) ans = "B"; else if (v[0].first == c3) ans = "C"; else ans = "D"; grc++; } if (grc > 1) cout << "C" << endl; else cout << ans << 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; char r(int x) { if (x == 0) return 'A'; else if (x == 1) return 'B'; else if (x == 2) return 'C'; else return 'D'; return ' '; } int main() { vector<string> all(4); int min, max; int maxp = 0; int minp = 0; for (int i = 0; i < 4; i++) { cin >> all[i]; if (i == 0) { min = all[i].size() - 2; max = min; } else { if (all[i].size() - 2 > max) { max = all[i].size() - 2; maxp = i; } if (all[i].size() - 2 < min) { min = all[i].size() - 2; minp = i; } } } bool minrightans = true; for (int i = 0; i < 4; i++) { if (i == minp) continue; if (min <= ((all[i].size() - 2) / 2)) minrightans = true; else { minrightans = false; break; } } bool maxrightans = true; for (int i = 0; i < 4; i++) { if (i == maxp) continue; if ((max / 2) >= (all[i].size() - 2)) maxrightans = true; else { maxrightans = false; break; } } if (maxrightans == true && minrightans == false) { cout << r(maxp) << endl; return 0; } else if (maxrightans == false && minrightans == true) { cout << r(minp) << endl; return 0; } 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
#include <bits/stdc++.h> using namespace std; long long MOD = 1e9 + 7, MAX = 1e18; struct wins { int st; int en; }; bool prime[1000001]; void Sieve(int n) { n = 1000000; memset(prime, true, sizeof(prime)); for (int p = 2; p * p <= n; p++) { if (prime[p] == true) { for (int i = p * p; i <= n; i += p) prime[i] = false; } } } bool func(long long n, long long d) { while (n > 0) { long long a = n % 10; if (a == d) { return true; } n = n / 10; } return false; } long long gcd(long long a, long long b) { if (a == 0) return b; if (b == 0) return a; if (a == b) return a; if (a > b) return gcd(a - b, b); return gcd(a, b - a); } long long bis(vector<long long> a, long long v, long long h, long long l) { long long m = (h + l) / 2; if (l > h) { return -1; } if (v > a[m]) { bis(a, v, h, m + 1); } else if (v < a[m]) { bis(a, v, m - 1, l); } if (v == a[m]) { return m; } } bool check(long long n) { long long l = 0; while (n > 0) { if (n % 10 != 4 && n % 10 != 7) { l = 1; break; } n = n / 10; } if (l == 0) return true; else return false; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); { long long n, ans = 0, x = 100, k = 0, sum = 0, y, m, a1, b1, c1, d1; vector<pair<long long, string>> v; string second[4], t, q; long long j = 0; for (long long i = 0; i < 4; i++) { cin >> second[i]; } long long a = second[0].length() - 2, b = second[1].length() - 2, c = second[2].length() - 2, d = second[3].length() - 2; v.push_back({a, "A"}); v.push_back({b, "B"}); v.push_back({c, "C"}); v.push_back({d, "D"}); sort(v.begin(), v.end()); if (v[0].first * 2 <= v[1].first && v[3].first < v[2].first * 2) { cout << v[0].second; } else if (v[3].first >= v[2].first * 2 && v[0].first * 2 > v[1].first) { cout << v[3].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
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.StringTokenizer; public class CF437A { public static void main(String[] args) { FastReader input = new FastReader(); PrintWriter pw = new PrintWriter(System.out); String s1 = input.nextLine(); String s2 = input.nextLine(); String s3 = input.nextLine(); String s4 = input.nextLine(); double sz1 = s1.length()-2; double sz2 = s2.length()-2; double sz3 = s3.length()-2; double sz4 = s4.length()-2; int great = 0; boolean A = false; boolean B = false; boolean C = false; boolean D = false; if(sz1 <= sz2/2 && sz1 <= sz3/2 && sz1 <= sz4/2 || sz1 >= sz2*2 && sz1 >= sz3 * 2 && sz1 >= sz4*2){ great++; A = true; } if(sz2 <= sz1/2 && sz2 <= sz3 / 2 && sz2 <= sz4/2 || sz2 >= sz1*2 && sz2 >= sz3 * 2 && sz2 >= sz4*2){ //System.out.println("here"); great++; B = true; } if(sz3 <= sz1/2 && sz3 <= sz2 / 2 && sz3 <= sz4/2 || sz3 >= sz1*2 && sz3 >= sz2 * 2 && sz3 >= sz4*2){ great++; C = true; } if(sz4 <= sz1/2 && sz4 <= sz2 / 2 && sz4 <= sz3/2 || sz4 >= sz1*2 && sz4 >= sz2 * 2 && sz4 >= sz3*2){ great++; D = true; } //System.out.println("great " + great); if(A && great == 1){ pw.println("A"); } else if(B && great == 1){ pw.println("B"); } else if(C && great == 1){ pw.println("C"); } else if(D && great == 1){ pw.println("D"); } else{ pw.println("C"); } pw.flush(); pw.close(); } 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
'''input A._ B.__ C.____ D.________ ''' i = sorted(enumerate([len(input()) - 2 for _ in range(4)]), key=lambda x: x[1]) a, b = False, False if all(2*i[0][1] <= i[x][1] for x in range(1, 4)): a = True if all(i[3][1] >= 2*i[y][1] for y in range(3)): b = True if a == b: print("C") elif a == True: print("ABCD"[i[0][0]]) else: print("ABCD"[i[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
#include <bits/stdc++.h> using namespace std; string ss[200]; int main() { pair<int, char> p[200]; for (int i = 1; i <= 4; i++) { cin >> ss[i]; p[i].first = ss[i].size() - 2; p[i].second = char(i + 64); } sort(p + 1, p + 5); if (p[1].first * 2 <= p[2].first && p[3].first * 2 > p[4].first) cout << p[1].second << endl; else if (p[3].first * 2 <= p[4].first && p[1].first * 2 > p[2].first) { cout << p[4].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
#include <bits/stdc++.h> using namespace std; int main() { string s; char mi, ma; int max = 0, min = INT_MAX; pair<int, char> p[4]; for (int i = 0; i < 4; ++i) { cin >> s; p[i].first = s.length() - 2; p[i].second = s[0]; } sort(p, p + 4); int flag1 = 0, flag2 = 0; for (int j = 1; j < 4; ++j) { if (2 * (p[0].first) <= p[j].first) flag1 += 1; } for (int j = 0; j < 3; ++j) { if (p[3].first >= 2 * (p[j].first)) flag2 += 1; } if (flag1 == 3 && flag2 != 3) cout << p[0].second << "\n"; else if (flag2 == 3 && flag1 != 3) cout << p[3].second << "\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
if __name__ == '__main__': lines = list() for i in range(4): lines.append([len(str(input())) - 2, i]) lines.sort(key=lambda x: x[0]) values = list() if lines[0][0] * 2 <= lines[1][0]: values.append(lines[0][1]) if lines[2][0] * 2 <= lines[3][0]: values.append(lines[3][1]) refer = 'ABCD' if len(values) == 1: print(refer[values[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
import java.util.Scanner; public class TheChildAndHomework { public static void main(String[] args) { Scanner scan = new Scanner(System.in); String temp; int[] v = new int[4]; int[] d = new int[4]; int[] r = new int[4]; for (int i = 0; i < 4; i++) { temp = scan.nextLine(); v[i] = temp.length() - 2; d[i] = 2 * v[i]; } boolean less = true; boolean more = true; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { if (i == j) continue; if (v[j] < d[i]) less = false; if (v[i] < d[j]) more = false; } if (less || more) r[i] = 1; less = more = true; } int res = -1; for (int i = 0; i < 4; i++) { if (res != -1 && r[i] == 1) { res = 2; i = 4; } if (res == -1 && r[i] == 1) res = i; } if (res == -1) 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; } } }
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 sys if __name__ == '__main__': a = len(sys.stdin.readline().strip()[2:]) b = len(sys.stdin.readline().strip()[2:]) c = len(sys.stdin.readline().strip()[2:]) d = len(sys.stdin.readline().strip()[2:]) data = [(a, 'A'),(b, 'B'),(c, 'C'),(d, 'D')] data.sort(key=lambda x:x[0]) start = data[0][0] count1 = 0 for i in xrange(1,4): if data[i][0] >= 2*start: count1 += 1 count2 = 0 end = data[3][0] for i in xrange(3): if 2*data[i][0] <= end: count2 += 1 if count1 == count2 or (count1 != 3 and count2 != 3): print "C" elif count1 == 3: print data[0][1] else: print data[3][1]
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] choice = "" choices = "" if min_len == answers_list[1][1]: choice = "C" else: if answers_list[1][1] >= 2 * min_len: choices += answers_list[0][0] else: choice = "C" max_len = answers_list[-1][1] if max_len == answers_list[-2][1]: choice = "C" else: if max_len >= 2 * answers_list[-2][1]: choices += answers_list[-1][0] else: choice = "C" 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
a = [] k = 0 for i in range(4): a.append(str(input())[2:]) for i in range(4): shorter, longer = True, True for j in range(4): if i != j: if len(a[i]) * 2 > len(a[j]): shorter = False if len(a[j]) * 2 > len(a[i]): longer = False if longer or shorter: k += 1 ans = i if k == 1: print(chr(ord('A') + 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
#include <bits/stdc++.h> using namespace std; int main() { char s[5][110]; int len[5], mark, i, j, num, temp, k; int c[5] = {0}; for (i = 1; i <= 4; i++) gets(s[i]); for (i = 1; i <= 4; i++) len[i] = strlen(s[i]) - 2; num = 0; for (i = 1; i <= 4; i++) { temp = 0; for (j = 1; j <= 4; j++) if (j != i && len[i] * 2 <= len[j]) temp++; if (temp < 3) { temp = 0; for (j = 1; j <= 4; j++) if (j != i && len[i] >= len[j] * 2) temp++; if (temp >= 3) num++, c[i] = 1; } else num++, c[i] = 1; } if (num == 1) { for (i = 1; i <= 4; i++) if (c[i] != 0) { printf("%c\n", i + 'A' - 1); break; } } 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
choice = ['A', 'B', 'C', 'D'] size = [] min_, max_, great, index = float("inf"), float("-inf"), 0, 0 for i in range(4): ch = input()[2:] size.append((len(ch), i+1)) min_, max_ = min(len(ch), min_), max(len(ch), max_) size.sort() if min_ <= size[1][0]//2: great += 1 index = size[0][1] if max_ >= size[-2][0]*2: great += 1 index = size[-1][1] if great == 1: print(choice[index-1]) 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
k = lambda x: len(x)-2 c = sorted([raw_input() for i in range(4)], key=k) l = map(k,c) f,g = 2*l[0] <= l[1], 2*l[2] <= l[3] if f and not g: print c[0][0] elif g and not f: print c[3][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
# http://codeforces.com/problemset/problem/437/A def getIndex(n): if n == 0: return "A" elif n == 1: return "B" elif n == 2: return "C" else: return "D" inp = [] for i in range(4): a = input() inp += [a.split(".")[1]] li = [] for x in inp: li += [len(x)] short = 2*min(li) count1 = 0 for i in li: if i >= short: count1 += 1 maxm = max(li) // 2 count2 = 0 for i in li: if i <= maxm: count2 += 1 if count1 == 3 and count2 != 3: print(getIndex(li.index(int(short // 2)))) elif count2 == 3 and count1 != 3: print(getIndex(li.index(int(maxm * 2)))) 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
from operator import itemgetter list = {} list['A'] =len(raw_input(""))-2 list['B'] =len(raw_input(""))-2 list['C'] =len(raw_input(""))-2 list['D'] =len(raw_input(""))-2 v=sorted(list.values()) if v[3]/v[2] >= 2 : if v[1]/v[0] >= 2 : print 'C' else : for i in list : if list[i] == v[3] : print i break else : if v[1]/v[0] >= 2 : for i in list : if list[i] == v[0] : print i break 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; string s[4]; bool so(int idx) { bool k1 = 1, k2 = 1; for (int i = 0; i < 4; i++) if (i != idx) k1 &= (s[idx].size() - 2) >= 2 * (s[i].size() - 2), k2 &= 2 * (s[idx].size() - 2) <= (s[i].size() - 2); return k1 || k2; } int main() { int n = 4; for (int i = 0; i < n; i++) cin >> s[i]; vector<int> a; for (int i = 0; i < 4; i++) if (so(i)) a.push_back(i); if (a.size() != 1) cout << "C\n"; else cout << char('A' + a[0]) << 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 main() { string s1, s2, s3, s4; cin >> s1 >> s2 >> s3 >> s4; vector<pair<int, char> > a(4); a[0].first = s1.size() - 2; a[0].second = 'A'; a[1].first = s2.size() - 2; a[1].second = 'B'; a[2].first = s3.size() - 2; a[2].second = 'C'; a[3].first = s4.size() - 2; a[3].second = 'D'; sort(a.begin(), a.end()); int n = 0; char answer; if (a[0].first * 2 <= a[1].first) { n++; answer = a[0].second; } if (a[2].first * 2 <= a[3].first) { n++; answer = a[3].second; } if (n != 1) { cout << "C"; } else { cout << answer; } }
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
str1 = raw_input() str2 = raw_input() str3 = raw_input() str4 = raw_input() l = [str1[2::],str2[2::],str3[2::],str4[2::]] l2 = [str1,str2,str3,str4] m = 0 n = 1000 saida1 = "" saida2 = "" for i in range(4): if len(l[i]) > m: m = len(l[i]) saida1 = l2[i] if len(l[i]) < n: n = len(l[i]) saida2 = l2[i] cont1 = 0 cont2 = 0 pode1 = True pode2 = True for e in l: if len(e) == m: cont1 += 1 if len(e) == n: cont2 += 1 if(m < 2*len(e) and m != len(e)): pode1 = False if(n*2 > len(e) and n != len(e)): pode2 = False if cont1 > 1: pode1 = False if cont2 > 1: pode2 = False if pode1 and pode2: print 'C' elif pode1: print saida1[0] elif pode2: print saida2[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.util.*; public class C437 { public static void main(String[] args) { Scanner sc= new Scanner(System.in); String s1=sc.next(); String s2=sc.next(); String s3=sc.next(); String s4=sc.next(); int len1=s1.length()-2; int len2=s2.length()-2; int len3=s3.length()-2; int len4=s4.length()-2; int a[]={len1,len2,len3,len4}; Arrays.sort(a); boolean Max = a[3] >= a[2] * 2; boolean Min = a[0] <= a[1] / 2; int ans=0; if(Max==Min) { ans =0; } else if(a[0]*2<=a[2]&&a[0]*2<=a[1]&&a[0]*2<=a[3]) { ans = a[0]; } else if(a[3]/2>=a[0]&&a[3]/2>=a[1]&&a[3]/2>=a[2]) { ans =a[3]; } if(ans==len1){ System.out.println("A"); } else if(ans==len2){ System.out.println("B"); } else if(ans==len4){ System.out.println("D"); } 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.util.ArrayList; import java.util.Scanner; public class T437A { public String solve(String[] a) { int[] l = new int[4]; for (int i = 0; i < 4; i ++) l[i] = a[i].length() - 2; ArrayList<Integer> ans = new ArrayList<Integer>(); for (int i = 0; i < 4; i ++) { boolean f1 = true; boolean f2 = true; for (int j = 0; j < 4; j ++) { if (i != j) { f1 = f1 && (l[i] / l[j] >= 2); f2 = f2 && (l[j] / l[i] >= 2); } } if (f1 || f2) ans.add(i); } if (ans.size() == 0 || ans.size() > 1) { return "C"; } else { if (ans.get(0) == 0) return "A"; else if (ans.get(0) == 1) return "B"; else if (ans.get(0) == 2) return "C"; else return "D"; } } public static void main(String[] args) { T437A t = new T437A(); /* String[] a1 = { "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" }; String[] a2 = { "A.ab", "B.abcde", "C.ab", "D.abc" }; String[] a3 = { "A.c", "B.cc", "C.c", "D.c" }; System.out.println(t.solve(a1)); System.out.println(t.solve(a2)); System.out.println(t.solve(a3)); */ Scanner in = new Scanner(System.in); String[] a = new String[4]; for (int i = 0; i < 4; i ++) a[i] = in.next(); System.out.println(t.solve(a)); } }
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.PrintWriter; import java.util.ArrayList; import java.util.Scanner; import java.util.StringTokenizer; /** * Created with IntelliJ IDEA. * User: AUtemuratov * Date: 07.04.14 * Time: 15:43 * To change this template use File | Settings | File Templates. */ public class Main { static FastReader fr = new FastReader(new BufferedReader(new InputStreamReader(System.in))); static PrintWriter pw = new PrintWriter(System.out); static int max = Integer.MIN_VALUE; static int min = Integer.MAX_VALUE; static int n,cnt,ind; static boolean ok = false; static String []s = new String[111]; public static void main(String[] args) throws Exception { n = 4; for (int i=1; i<=n; i++) { String t = fr.nextToken(); s[i] = t.substring(2); } for (int i=1; i<=n; i++) { ok = false; for (int j=1; j<=n; j++) { if (i==j) continue; if (2*s[i].length()>(s[j].length())) { ok = true; break; } } if (!ok) { cnt++; ind = i; } } for (int i=1; i<=n; i++) { ok = false; for (int j=1; j<=n; j++) { if (i==j) continue; if (s[i].length()/2<(s[j].length())) { ok = true; break; } } if (!ok) { cnt++; ind = i; } } //pw.println(cnt); if (cnt==1) { //pw.println(ind); if (ind==1) pw.println("A"); if (ind==2) pw.println("B"); if (ind==3) pw.println("C"); if (ind==4) pw.println("D"); } else { pw.println("C"); } pw.close(); } } class Pair { int x,y; public Pair (int x, int y) { this.x = x; this.y = y; } } class FastReader { BufferedReader bf; StringTokenizer tk = null; String DELIM = " "; public FastReader(BufferedReader bf) { this.bf = bf; } public String nextToken() throws Exception { if(tk==null || !tk.hasMoreTokens()) { tk = new StringTokenizer(bf.readLine(),DELIM); } return tk.nextToken(); } public int nextInt() throws Exception { return Integer.parseInt(nextToken()); } public int nextLong() throws Exception { return Integer.parseInt(nextToken()); } public int nextDouble() throws Exception { return Integer.parseInt(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
#include <bits/stdc++.h> using namespace std; char st[4][150] = {0}; int main() { int minn = 100000000, maxx = 0, bj1 = 0, bj2 = 0, i, j, k, l, s, t, k1 = 0, k2 = 0, result = -1; int a[4]; for (i = 0; i <= 3; i++) { gets(st[i]); a[i] = strlen(st[i]) - 2; if (minn > a[i]) minn = a[i], k1 = i; if (maxx < a[i]) maxx = a[i], k2 = i; } for (i = 0; i <= 3; i++) { if (!(minn <= a[i] / 2)) bj1++; if (!(maxx >= a[i] * 2)) bj2++; } if (bj1 == 1 && bj2 != 1) result = k1; if (bj1 != 1 && bj2 == 1) { if (result == k1) { printf("C\n"); return 0; } result = k2; } if (result == -1) { printf("C\n"); } else printf("%c\n", result + 'A'); }
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((raw_input()))-2 b = len((raw_input()))-2 c = len((raw_input()))-2 d = len((raw_input()))-2 l = [] for i in xrange(102): l.append(0) l[a]+=1 l[b]+=1 l[c]+=1 l[d]+=1 ans = [] ch = 0 if ch: print "C" else: if (a <= b/2 and a <= c/2 and a <= d/2) or (a >= 2*b and a >= c*2 and a >= d*2): ans.append("A") if (b <= a/2 and b <= c/2 and b <= d/2) or (b >= a*2 and b >= c*2 and b >= d*2): ans.append("B") if (c <= b/2 and c <= a/2 and c <= d/2) or (c >= b*2 and c >= a*2 and c >= d*2): ans.append("C") if (d <= b/2 and d <= a/2 and d <= c/2) or (d >= b*2 and d >= a*2 and d >= c*2): ans.append("D") 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
variants = [len(input()[2:]) for i in range(4)] is_awesome = [1]*4 for i in range(4): for j in range(4): if i != j and (not variants[i] * 2 <= variants[j]): is_awesome[i] = 0 if not is_awesome[i]: is_awesome[i] = 1 for j in range(4): if i != j and (not variants[i] / 2 >= variants[j]): is_awesome[i] = 0 if sum(is_awesome) == 1: print(chr(ord('A') + is_awesome.index(1))) 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> #pragma comment(linker, "/STACK:512000000") using namespace std; template <class telem> telem MAX(telem a, telem b) { return (a > b) ? a : b; } template <class telem> telem MIN(telem a, telem b) { return (a < b) ? a : b; } template <class telem> telem GCD(telem a, telem b) { return b ? GCD(b, a % b) : a; } template <class telem> telem LCM(telem a, telem b) { return a / GCD(a, b) * b; } template <class telem> telem UNSIGNED(telem a) { return (a > 0) ? a : a * (-1); } template <class telem> void bez_swop(telem &a, telem &b) { telem c = a; a = b; b = c; } void swop(int &a, int &b) { a = a ^ b; b = a ^ b; a = a ^ b; } pair<string, string> s[4]; bool cmp(pair<string, string> a, pair<string, string> b) { return a.first.size() < b.first.size(); } int main() { ios_base::sync_with_stdio(false); srand(time(NULL)); time_t start = clock(); string tmp; vector<string> ans; for (int i = 0; i < 4; i++) { cin >> tmp; s[i].first = tmp.substr(2); s[i].second = tmp.substr(0, 1); } sort(s, s + 4, cmp); if (2 * s[0].first.size() <= s[1].first.size()) ans.push_back(s[0].second); if (s[3].first.size() >= s[2].first.size() * 2) ans.push_back(s[3].second); if (ans.size() == 1) cout << ans[0]; 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 = raw_input() b = raw_input() c = raw_input() d = raw_input() a_length = len(a) - 2 b_length = len(b) - 2 c_length = len(c) - 2 d_length = len(d) - 2 tuple_a = (a_length,a[2:], 'A') tuple_b = (b_length, b[2:], 'B') tuple_c = (c_length, c[2:], 'C') tuple_d = (d_length, d[2:], 'D') tuples = [tuple_a, tuple_b, tuple_c, tuple_d] tuples.sort() check_1 = 2 * tuples[0][0] <= tuples[1][0] and tuples[0][2] != tuples[1][2] check_2 = tuples[3][0] >= 2 * tuples[2][0] and tuples[3][2] != tuples[2][2] if check_1 and not check_2: print tuples[0][2] elif check_2 and not check_1: print tuples[3][2] 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> #pragma GCC optimize("unroll-loops,no-stack-protector") #pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") using namespace std; const int MOD = 1e9 + 7; const int INF32 = 1 << 30; const long long INF64 = 1LL << 60; void solve() { string A, B, C, D; cin >> A >> B >> C >> D; int x[4]; x[0] = A.size(); x[1] = B.size(); x[0] -= 2; x[1] -= 2; x[2] = C.size(); x[3] = D.size(); x[2] -= 2; x[3] -= 2; int aa = x[0], bb = x[1], cc = x[2], dd = x[3]; sort(x, x + 4); int rec = 0; char ans; if (x[1] >= 2 * x[0]) { if (x[0] == aa) { rec++; ans = 'A'; } if (x[0] == bb) { rec++; ans = 'B'; } if (x[0] == cc) { rec++; ans = 'C'; } if (x[0] == dd) { rec++; ans = 'D'; } } if (x[3] >= 2 * x[2]) { if (x[3] == aa) { rec++; ans = 'A'; } if (x[3] == bb) { rec++; ans = 'B'; } if (x[3] == cc) { rec++; ans = 'C'; } if (x[3] == dd) { rec++; ans = 'D'; } } if (rec - 1) cout << 'C'; else cout << ans; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); solve(); 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() { char s[4][105]; int len[4], i, j, c = 0, ans; bool greatest = 1, least = 1; for (i = 0; i < 4; i++) { cin >> s[i]; len[i] = strlen(s[i]) - 2; } for (i = 0; i < 4; i++) { greatest = 1; least = 1; for (j = 0; j < 4; j++) { if (i == j) continue; if (len[i] < 2 * len[j]) greatest = 0; if (len[i] * 2 > len[j]) least = 0; } if (greatest || least) { c++; ans = i; } } char a = 'A' + ans; if (c == 1) cout << a << 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
__author__ = 'asmn' import sys #sys.stdin = open('in') description = [chr(i + ord('A')) + input().strip()[3:] for i in range(4)] description.sort(key=lambda s: len(s)) long_exist = (len(description[3]) >= len(description[2]) * 2) short_exist = (len(description[0]) * 2 <= len(description[1])) if long_exist and not short_exist: print(description[3][0]) elif short_exist and not long_exist: print(description[0][0]) else: print('C') #print(list(map(len, description))) #print(short_exist,long_exist)
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.*; public class Main { public static void main(String[] args){ solve(); return; } static void solve(){ Scanner scn = new Scanner(System.in); String[] d = new String[4]; int[] l = new int[4]; for(int i=0;i<4;i++){ d[i] = scn.nextLine(); l[i] = d[i].length()-2; } int lcount=0; int lindex=-1; int scount=0; int sindex=-1; for(int i=0;i<4;i++){ int sok=0; int lok=0; for(int j=0;j<4;j++){ if(i==j) continue; //twice shorter if(l[i]*2<=l[j]) sok++; //twice longer if(l[j]*2<=l[i]) lok++; } if(lok==3){ lcount++; lindex=i; } if(sok==3){ scount++; sindex=i; } } String[] ans = {"A","B","C","D"}; if(scount==1 && lcount==0){ System.out.println(ans[sindex]); }else if(scount==0 && lcount==1){ System.out.println(ans[lindex]); }else{ System.out.println("C"); } return; } }
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
s1=input() s2=input() s3=input() s4=input() l1=len(s1)-2 l2=len(s2)-2 l3=len(s3)-2 l4=len(s4)-2 ll=[[l1,"A"],[l2,"B"],[l3,"C"],[l4,"D"]] ll.sort() if(ll[0][0]<=ll[1][0]/2 and ll[-1][0]>=ll[-2][0]*2): print("C") elif(ll[0][0]<=ll[1][0]/2): print(ll[0][1]) elif(ll[-1][0]>=ll[-2][0]*2): print(ll[-1][1]) 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.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Scanner; public class A { public static void main(String[] args) { Scanner in = new Scanner(System.in); String s; ArrayList<Node> size = new ArrayList<Node>(); for (int i = 0; i < 4; i++) { s = in.next(); Node n = new Node(s.length() - 2, (char) (i + 65)); size.add(n); } Collections.sort(size); char ans = 'C'; int x = 0; if (size.get(0).x * 2 <= size.get(1).x) { ans = size.get(0).y; x++; } if ((size.get(size.size() - 1).x >= size.get(size.size() - 2).x* 2)) { ans = size.get(size.size() - 1).y; x++; } if(x==2) ans='C'; System.out.println(ans); } } class Node implements Comparable<Node> { int x; char y; public Node(int x, char y) { this.x = x; this.y = y; } @Override public int compareTo(Node o) { // TODO Auto-generated method stub return this.x - o.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
import java.util.Scanner; public class JavaApplication2 { public static void main(String[] args) { Scanner sc=new Scanner(System.in); String s=sc.nextLine(); String a=s.substring(2,s.length()); s=sc.nextLine(); String b=s.substring(2,s.length()); s=sc.nextLine(); String c=s.substring(2,s.length()); s=sc.nextLine(); String d=s.substring(2,s.length()); int a1=a.length(); int b1=b.length(); int c1=c.length(); int d1=d.length(); String ans="";int cnt=0; if(a1*2<=b1 && a1*2<=c1 && a1*2<=d1){ans="A";cnt++;} else if(a1>=2*b1 && a1>=2*c1 && a1>=2*d1){ans="A";cnt++;} if(b1*2<=a1 && b1*2<=c1 && b1*2<=d1){ans="B";cnt++;} else if(b1>=2*a1 && b1>=2*c1 && b1>=2*d1){ans="B";cnt++;} if(c1*2<=a1 && c1*2<=b1 && c1*2<=d1){ans="C";cnt++;} else if(c1>=2*a1 && c1>=2*b1 && c1>=2*d1){ans="C";cnt++;} if(d1*2<=a1 && d1*2<=c1 && d1*2<=b1){ans="D";cnt++;} else if(d1>=2*a1 && d1>=2*c1 && d1>=2*b1){ans="D";cnt++;} if(cnt==0 || cnt>=2) System.out.println('C'); else System.out.println(ans); } }
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.ArrayList; import java.util.List; public class Task437A { public static void main(String... args) throws NumberFormatException, IOException { Solution.main(System.in, System.out); } static class Scanner { private final BufferedReader br; private String[] cache; private int cacheIndex; Scanner(InputStream is) { br = new BufferedReader(new InputStreamReader(is)); cache = new String[0]; cacheIndex = 0; } int nextInt() throws IOException { if (cacheIndex >= cache.length) { cache = br.readLine().split(" "); cacheIndex = 0; } return Integer.parseInt(cache[cacheIndex++]); } long nextLong() throws IOException { if (cacheIndex >= cache.length) { cache = br.readLine().split(" "); cacheIndex = 0; } return Long.parseLong(cache[cacheIndex++]); } String next() throws IOException { if (cacheIndex >= cache.length) { cache = br.readLine().split(" "); cacheIndex = 0; } return cache[cacheIndex++]; } String nextLine() throws IOException { return br.readLine(); } void close() throws IOException { br.close(); } } static class Solution { public static void main(InputStream is, OutputStream os) throws NumberFormatException, IOException { PrintWriter pw = new PrintWriter(os); Scanner sc = new Scanner(is); String ansA = sc.nextLine().substring(2); String ansB = sc.nextLine().substring(2); String ansC = sc.nextLine().substring(2); String ansD = sc.nextLine().substring(2); List<String> greatChooses = new ArrayList<>(4); if (ansA.length() <= Math.min(ansB.length(), Math.min(ansC.length(), ansD.length())) / 2 || ansA.length() >= Math.max(ansB.length(), Math.max(ansC.length(), ansD.length())) * 2) { greatChooses.add("A"); } if (ansB.length() <= Math.min(ansA.length(), Math.min(ansC.length(), ansD.length())) / 2 || ansB.length() >= Math.max(ansA.length(), Math.max(ansC.length(), ansD.length())) * 2) { greatChooses.add("B"); } if (ansC.length() <= Math.min(ansA.length(), Math.min(ansB.length(), ansD.length())) / 2 || ansC.length() >= Math.max(ansA.length(), Math.max(ansB.length(), ansD.length())) * 2) { greatChooses.add("C"); } if (ansD.length() <= Math.min(ansA.length(), Math.min(ansB.length(), ansC.length())) / 2 || ansD.length() >= Math.max(ansA.length(), Math.max(ansB.length(), ansC.length())) * 2) { greatChooses.add("D"); } if(greatChooses.size() == 1){ pw.println(greatChooses.get(0)); } else { pw.println("C"); } pw.flush(); sc.close(); } } }
JAVA