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() { string a, b, c, d; cin >> a >> b >> c >> d; int first = a.size() - 2; int second = b.size() - 2; int z = c.size() - 2; int w = d.size() - 2; int n = 0, m = 0; if ((first <= second / 2) && (first <= z / 2) && (first <= w / 2)) { ++n; a = ""; } if ((second <= first / 2) && (second <= z / 2) && (second <= w / 2)) { ++n; b = ""; } if ((z <= second / 2) && (z <= first / 2) && (z <= w / 2)) { ++n; c = ""; } if ((w <= second / 2) && (w <= z / 2) && (w <= first / 2)) { ++n; d = ""; } if ((first >= second * 2) && (first >= z * 2) && (first >= w * 2)) { ++n; a = ""; } if ((second >= first * 2) && (second >= z * 2) && (second >= w * 2)) { ++n; b = ""; } if ((z >= second * 2) && (z >= first * 2) && (z >= w * 2)) { ++n; c = ""; } if ((w >= second * 2) && (w >= z * 2) && (w >= first * 2)) { ++n; d = ""; } if (n == 1) { if (a == "") cout << 'A'; if (b == "") cout << 'B'; if (c == "") cout << 'C'; if (d == "") cout << 'D'; } else cout << 'C'; }
CPP
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
import sys lines = sys.stdin.readlines() lines = map(lambda x: x.strip(), lines) lengths = [] mapping = {} for line in lines: a, b = line.split('.') lengths.append(len(b)) mapping[len(b)] = a lengths.sort() a = lengths[0] * 2 <= lengths[1] b = lengths[-1] >= lengths[-2] * 2 if a and not b: print(mapping[lengths[0]]) elif b and not a: print(mapping[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 b=len(input())-2 c=len(input())-2 d=len(input())-2 cnt=0 ans='e' if (a>=b*2 and a>=c*2 and a>=d*2) or (a*2<=b and a*2<=c and a*2<=d) : ans='A' cnt+=1 a , b = b , a if (a>=b*2 and a>=c*2 and a>=d*2) or (a*2<=b and a*2<=c and a*2<=d) : ans='B' cnt+=1 a,c=c,a if (a>=b*2 and a>=c*2 and a>=d*2) or (a*2<=b and a*2<=c and a*2<=d) : ans='C' cnt+=1 a,d=d,a if (a>=b*2 and a>=c*2 and a>=d*2) or (a*2<=b and a*2<=c and a*2<=d) : ans='D' cnt+=1 if cnt > 1 or cnt ==0: 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
a=[len(raw_input()[2:]) for i in range(4)] ans='ABCD' ii=0 cnt=0 for i in range(4): _short, _long = 0, 0 for j in range(4): if i!=j and a[i]>=2*a[j]: _long+=1 if i!=j and a[i]*2<=a[j]: _short+=1 if _short==3 or _long==3: ii=i cnt+=1 if cnt==1: print ans[ii] else: print 'C'
PYTHON
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
l=[] ans=[1]*4 for i in range(4): s=raw_input() chk=len(s)-2 # chk-=s.count('_') l.append(chk) a=max(l) i=min(l) for x in range(4): if l[x]!=a and l[x]!=i: ans[x]=0 else: for y in range(4): if x==y: pass elif l[x]==a and l[y]*2>a: ans[x]=0 elif l[x]==i and l[y]<i*2: ans[x]=0 print 'C' if ans.count(1)!=1 else chr(ans.index(1)+65)
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.Scanner; public class solu_11 { public static void main(String[] args) { Scanner in = new Scanner(System.in); String a = in.next(); String b = in.next(); String c = in.next(); String d = in.next(); int tam1 = a.substring(2, a.length()).length(); int tam2 = b.substring(2, b.length()).length(); int tam3 = c.substring(2, c.length()).length(); int tam4 = d.substring(2, d.length()).length(); int ar[] = new int[4]; String let[] = {a, b, c, d}; ar[0] = tam1; ar[1] = tam2; ar[2] = tam3; ar[3] = tam4; int may = Math.max(Math.max(Math.max(tam1, tam2), tam3), tam4); int min = Math.min(Math.min(Math.min(tam1, tam2), tam3), tam4); int j = 0; int k = 0; for (int i = 0; i < 4; i++) { if (min * 2 <= ar[i]) { j++; } if (may >= ar[i] * 2) { k++; } } if (j == 3 && j!=k) { if (min == tam1) { System.out.println("A"); } else if (min == tam2) { System.out.println("B"); } else if (min == tam3) { System.out.println("C"); } else { System.out.println("D"); } } else if (k == 3 && k!=j) { if (may== tam1) { System.out.println("A"); } else if (may == tam2) { System.out.println("B"); } else if (may== tam3) { System.out.println("C"); } else { 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
# Description of the problem can be found at http://codeforces.com/problemset/problem/437/A max_i = -1 max_l = "A" min_i = -1 min_l = 100 c = "E" l_s = list() for _ in range(4): l_s.append(input()) l_s.sort(key = lambda x: len(x)) if (len(l_s[0]) - 2) * 2 <= len(l_s[1]) - 2: if len(l_s[3]) - 2 >= (len(l_s[2]) - 2) * 2: print("C") else: print(l_s[0][0]) elif len(l_s[3]) - 2 >= (len(l_s[2]) - 2) * 2: print(l_s[3][0]) else: print("C")
PYTHON3
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
#include <bits/stdc++.h> using namespace std; int main() { string s[4]; int size[4]; for (int i = 0; i < 4; i++) { cin >> s[i]; size[i] = s[i].size() - 2; } int c1 = 0, c2 = 0, f = 0; char choice; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { if (i != j) { if (size[i] <= size[j] * 0.5) { c1++; } if (size[i] * 0.5 >= size[j]) { c2++; } } } if ((c1 == 3 && c2 != 3) || (c1 != 3 && c2 == 3)) { choice = 65 + i; f++; } c1 = c2 = 0; } if (f == 0 || f != 1) cout << "C" << endl; else cout << choice << 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_base::sync_with_stdio(0); vector<string> v(4); vector<char> X; for (int i = 0; i < 4; i++) { cin >> v[i]; } int c, j, i, k; bool f = false; for (i = 0; i < 4; i++) { c = 0; k = 0; for (j = 0; j < 4; j++) { if (i != j) { if ((v[i].size() - 2) * 2 <= (v[j].size() - 2)) { c++; } if ((v[i].size() - 2) >= (v[j].size() - 2) * 2) { k++; } } } if (c == 3 || k == 3) { X.push_back('A' + i); f = true; } } if (!f || X.size() > 1) cout << "C" << endl; else cout << X[0] << 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
a=[0,0,0,0] ans_str=['A','B','C','D'] def is_great(_index): for i in range(4): if a[_index] < (a[i]*2) and _index != i: return False return True def is_smaller(_index): for i in range(4): if a[_index]*2 > a[i] and _index != i: return False return True for i in range(4): a[i]=len(raw_input())-2 ans=-1 cnt = 0 for i in range(4): if is_great(i) or is_smaller(i): ans = i cnt += 1 if 1 == cnt: print ans_str[ans] else: print 'C'
PYTHON
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
#include <bits/stdc++.h> using namespace std; int main() { string s1, s2, s3, s4; cin >> s1 >> s2 >> s3 >> s4; int n1 = s1.size() - 2; int n2 = s2.size() - 2; int n3 = s3.size() - 2; int n4 = s4.size() - 2; int a = 0, b = 0, c = 0, d = 0; if ((2 * n1 <= n2 && 2 * n1 <= n3 && 2 * n1 <= n4) || (n1 >= 2 * n2 && n1 >= 2 * n3 && n1 >= 2 * n4)) a = 1; if ((2 * n2 <= n1 && 2 * n2 <= n3 && 2 * n2 <= n4) || (n2 >= 2 * n1 && n2 >= 2 * n3 && n2 >= 2 * n4)) b = 1; if ((2 * n3 <= n1 && 2 * n3 <= n2 && 2 * n3 <= n4) || (n3 >= 2 * n1 && n3 >= 2 * n1 && n3 >= 2 * n4)) c = 1; if ((2 * n4 <= n1 && 2 * n4 <= n2 && 2 * n4 <= n3) || (n4 >= 2 * n1 && n4 >= 2 * n2 && n4 >= 2 * n3)) d = 1; if (a + b + c + d > 1) { cout << 'C'; return 0; } if (a) { cout << 'A'; return 0; } if (b) { cout << 'B'; return 0; } if (c) { cout << 'C'; return 0; } if (d) { cout << 'D'; return 0; } 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.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; import java.util.StringTokenizer; public class Main { FastScanner in; PrintWriter out; void solve() { int[] arr = new int[4]; for(int i=0 ; i<4 ; i++) arr[i] = in.next().length()-2; int count = 0; char[] s = {'A','B','C','D'}; char c = 'C'; for(int i=0 ; i<4 ; i++) { int c1 = 0, c2 = 0; for(int j=0 ; j<4 ; j++) { if(i == j) continue; if(arr[i] >= arr[j]*2) c1++; if(arr[i]*2 <= arr[j]) c2++; } if(c1 > 2 || c2 > 2) { count++; c = s[i]; } } out.print((count == 1) ? c : 'C'); } void runIO() { in = new FastScanner(System.in); out = new PrintWriter(System.out); solve(); out.close(); } void run() { try { in = new FastScanner(new File("test.in")); out = new PrintWriter(new File("test.out")); solve(); out.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } } class FastScanner { BufferedReader br; StringTokenizer st; public FastScanner(File f) { try { br = new BufferedReader(new FileReader(f)); } catch (FileNotFoundException e) { e.printStackTrace(); } } public FastScanner(InputStream f) { br = new BufferedReader(new InputStreamReader(f)); } String next() { while (st == null || !st.hasMoreTokens()) { String s = null; try { s = br.readLine(); } catch (IOException e) { e.printStackTrace(); } if (s == null) return null; st = new StringTokenizer(s); } return st.nextToken(); } String nextln() { String s = null; while (st == null || !st.hasMoreTokens()) { try { s = br.readLine(); } catch (IOException e) { e.printStackTrace(); } if (s == null) return null; st = new StringTokenizer(s); } return s; } boolean hasMoreTokens() { while (st == null || !st.hasMoreTokens()) { String s = null; try { s = br.readLine(); } catch (IOException e) { e.printStackTrace(); } if (s == null) return false; st = new StringTokenizer(s); } return true; } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } double nextDouble() { return Double.parseDouble(next()); } } public static void main(String[] args) { new Main().runIO(); } } class Pair { int first; int second; Pair(int first, int second) { this.first = first; this.second = second; } } class Node { int value; ArrayList<Integer> edges = new ArrayList<Integer>(); Node(int v) { this.value = v; } }
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
r=[] for i in range(4): r+=[raw_input()] r[i]=len(r[i])-2 w=r[:] w.sort() if 2*w[0]>w[1] and 2*w[2]>w[-1]: print'C' if 2*w[0]<=w[1]: if 2*w[2]<=w[-1]: print 'C' else: print '%c'%chr(ord('A')+(r.index(w[0]))) if 2*w[0]>w[1] and 2*w[2]<=w[-1]: print '%c'%chr(ord('A')+(r.index(w[-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
#!/usr/bin/env python3 choice = list() for i in range(4): choice.append(len(input())-2) great = -1 for i in range(4): shorter = 0 longer = 0 for j in range(4): if j == i: continue if 2*choice[i] <= choice[j]: shorter += 1 if choice[i] >= 2*choice[j]: longer += 1 if shorter == 3 or longer == 3: if great == -1: great = i else: print('C') quit() if great == -1 or great == 2: print('C') elif great == 0: print('A') elif great == 1: print('B') elif great == 3: 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.util.Scanner; public class homework { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int[] a = new int[4]; for (int i = 0; i < a.length; i++) a[i] = sc.nextLine().length() - 2; int k1 = 0; String x = ""; for (int i = 0; i < a.length; i++) { int k = 0; int p = 0; for (int j = 0; j < a.length; j++) { if (j != i) { if (a[i] >= 2 * a[j]) k++; } } for (int j = 0; j < a.length; j++) { if (j != i) { if (a[i] <= a[j] / 2) p++; } } if (k == 3 || p == 3) { x += Integer.toString(i); } } if (x.length() == 1) { if(Integer.parseInt(x)==0){ System.out.println("A"); } else if(Integer.parseInt(x)==1){ System.out.println("B"); } else if(Integer.parseInt(x)==2){ System.out.println("C"); } else if(Integer.parseInt(x)==3){ System.out.println("D"); } } else System.out.println("C"); } }
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 getChar(x): if x == 0: return 'A' if x == 1: return 'B' if x == 2: return 'C' return 'D' arr = [] for i in range(4): s = input() arr.append((i,s[2:])) for i in range(4): for j in range(i + 1, 4): if len(arr[j][1]) < len(arr[i][1]): tmp = arr[j] arr[j] = arr[i] arr[i] = tmp counter = 0 great = -1 if len(arr[0][1]) * 2 <= len(arr[1][1]): great = arr[0][0] counter = counter + 1 if len(arr[3][1]) >= len(arr[2][1]) * 2: great = arr[3][0] counter = counter + 1 if counter == 2 or counter == 0: print('C') else: print(getChar(great))
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
mod = 1000000007 MOD = 998244353 ii = lambda : int(input()) si = lambda : input() dgl = lambda : list(map(int, input())) f = lambda : map(int, input().split()) il = lambda : list(map(int, input().split())) it = lambda : tuple(map(int, input().split())) ls = lambda : list(input()) l = [] for i in range(4): s = si() l.append([len(s)-2,i]) l.sort() if all(l[0][0]*2<=l[i][0] for i in range(1, 4)) and all(l[-1][0]//2>=l[i][0] for i in range(3)): print('C') elif all(l[0][0]*2 <= l[i][0] for i in range(1, 4)): print(chr(l[0][1]+ord('A'))) elif all(l[-1][0]//2 >= l[i][0] for i in range(3)): print(chr(l[-1][1]+ord('A'))) 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; const int N = 300000; bool used[5]; bool check(int k1, int k2, int k3, int k4) { if (k1 >= 2 * k2 && k1 >= 2 * k3 && k1 >= 2 * k4) return true; if (2 * k1 <= k2 && 2 * k1 <= k3 && 2 * k1 <= k4) return true; return false; } int main() { string s1, s2, s3, s4; cin >> s1; scanf("\n"); cin >> s2; scanf("\n"); cin >> s3; scanf("\n"); cin >> s4; scanf("\n"); int k1 = s1.length() - 2, k2 = s2.length() - 2, k3 = s3.length() - 2, k4 = s4.length() - 2; memset(used, false, sizeof(used)); if (check(k1, k2, k3, k4)) used[1] = true; if (check(k2, k1, k3, k4)) used[2] = true; if (check(k3, k1, k2, k4)) used[3] = true; if (check(k4, k1, k2, k3)) used[4] = true; char ans = 'C'; int k = 0; for (int i = 1; i <= 4; i++) if (used[i]) k++; if (k == 1) { if (used[1]) ans = 'A'; if (used[2]) ans = 'B'; if (used[4]) ans = 'D'; } cout << ans; 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 mod = 1000000007; int gcd(int a, int b) { int r, i; while (b != 0) { r = a % b; a = b; b = r; } return a; } struct ax { int s; char in; }; bool cmp(struct ax a, struct ax b) { return a.s < b.s; } int main() { char a[10010]; char b[10010]; char c[10010]; char d[10010]; struct ax aa[5]; int t, i, j, n, m, k, p; cin >> a; cin >> b; cin >> c; cin >> d; aa[0].s = strlen(a) - 2; aa[1].s = strlen(b) - 2; aa[2].s = strlen(c) - 2; aa[3].s = strlen(d) - 2; aa[0].in = 'A'; aa[1].in = 'B'; aa[2].in = 'C'; aa[3].in = 'D'; sort(aa, aa + 4, cmp); if (2 * aa[0].s <= aa[1].s && aa[3].s >= 2 * aa[2].s) { cout << "C\n"; } else if (2 * aa[0].s <= aa[1].s) { cout << aa[0].in << "\n"; } else if (aa[3].s >= 2 * aa[2].s) { cout << aa[3].in << "\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
a = len(input()) - 2 b = len(input()) - 2 c = len(input()) - 2 d = len(input()) - 2 l = [(a, "A"), (b, "B"), (c, "C"), (d, "D")] l.sort() s = False #print(l) if l[0][0] * 2 <= l[1][0]: s = l[0][1] if l[2][0] * 2 <= l[3][0]: if s: print("C") exit() s = l[3][1] if s: print(s) 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; const long long inf = 0x3f3f3f3f; string a, b, c, d; int n[5]; char tc[5]; int main() { std::ios::sync_with_stdio(0); cin >> a >> b >> c >> d; int cnt = 0, id; tc[1] = 'A', tc[2] = 'B', tc[3] = 'C', tc[4] = 'D'; n[1] = int((a).size()) - 2, n[2] = int((b).size()) - 2, n[3] = int((c).size()) - 2, n[4] = int((d).size()) - 2; for (int i = 1; i <= 4; ++i) { int x = 0, y = 0; for (int j = 1; j <= 4; ++j) { if (i == j) continue; if (n[i] * 2 <= n[j]) x++; else if (n[i] >= n[j] * 2) y++; } if (x == 3 || y == 3) { id = i; cnt++; if (cnt == 2) { cout << "C" << endl; return 0; } } } if (cnt == 0) cout << "C" << endl; else cout << tc[id] << 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
# -*- coding: utf-8 -*- 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
# Codeforces Problemset # 437A a = len(input()) - 2 b = len(input()) - 2 c = len(input()) - 2 d = len(input()) - 2 great = [] if 2*a <= b and 2*a <= c and 2*a <= d: great.append('A') elif 2*b <= a and 2*b <= c and 2*b <= d: great.append('B') elif 2*c <= a and 2*c <= b and 2*c <= d: great.append('C') elif 2*d <= a and 2*d <= b and 2*d <= c: great.append('D') if a >= 2*b and a >= 2*c and a >= 2*d: great.append('A') elif b >= 2*a and b >= 2*c and b >= 2*d: great.append('B') elif c >= 2*a and c >= 2*b and c >= 2*d: great.append('C') elif d >= 2*a and d >= 2*b and d >= 2*c: great.append('D') if len(great) == 1: print(great[0]) else: print('C')
PYTHON3
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
#include <bits/stdc++.h> using namespace std; int main() { string a, b, c, d; cin >> a >> b >> c >> d; int c1 = 0, c2 = 0, c3 = 0, c4 = 0; if ((a.size() - 2) >= (b.size() - 2) * 2 && (a.size() - 2) >= (c.size() - 2) * 2 && (a.size() - 2) >= (d.size() - 2) * 2) { c1 = 1; } else if ((a.size() - 2) * 2 <= (b.size() - 2) && (a.size() - 2) * 2 <= (c.size() - 2) && (a.size() - 2) * 2 <= (d.size() - 2)) { c1 = 1; } if ((b.size() - 2) >= (a.size() - 2) * 2 && (b.size() - 2) >= (c.size() - 2) * 2 && (b.size() - 2) >= (d.size() - 2) * 2) { c2 = 1; } else if ((b.size() - 2) * 2 <= (a.size() - 2) && (b.size() - 2) * 2 <= (c.size() - 2) && (b.size() - 2) * 2 <= (d.size() - 2)) { c2 = 1; } if ((c.size() - 2) >= (a.size() - 2) * 2 && (c.size() - 2) >= (b.size() - 2) * 2 && (c.size() - 2) >= (d.size() - 2) * 2) { c3 = 1; } else if ((c.size() - 2) * 2 <= (a.size() - 2) && (c.size() - 2) * 2 <= (b.size() - 2) && (c.size() - 2) * 2 <= (d.size() - 2)) { c3 = 1; } if ((d.size() - 2) >= (a.size() - 2) * 2 && (d.size() - 2) >= (b.size() - 2) * 2 && (d.size() - 2) >= (c.size() - 2) * 2) { c4 = 1; } else if ((d.size() - 2) * 2 <= (a.size() - 2) && (d.size() - 2) * 2 <= (b.size() - 2) && (d.size() - 2) * 2 <= (c.size() - 2)) { c4 = 1; } if (c1 + c2 + c3 + c4 > 1 || c1 + c2 + c3 + c4 == 0) cout << c[0] << endl; else { if (c1 == 1) cout << a[0] << endl; else if (c2 == 1) cout << b[0] << endl; else if (c3 == 1) cout << c[0] << endl; else if (c4 == 1) cout << d[0] << 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, ans; int z, y, x, k, cnt; int main() { cin >> a >> b >> c >> d; x = a.size() - 2; y = b.size() - 2; z = c.size() - 2; k = d.size() - 2; if (x <= y / 2 && x <= z / 2 && x <= k / 2 || y * 2 <= x && z * 2 <= x && k * 2 <= x) { cnt++; ans = 'A'; } if (y <= x / 2 && y <= z / 2 && y <= k / 2 || x * 2 <= y && z * 2 <= y && k * 2 <= y) { cnt++; ans = 'B'; } if (z <= y / 2 && z <= x / 2 && z <= k / 2 || y * 2 <= z && x * 2 <= z && k * 2 <= z) { cnt++; ans = 'C'; } if (k <= y / 2 && k <= z / 2 && k <= x / 2 || y * 2 <= k && z * 2 <= k && x * 2 <= k) { cnt++; ans = 'D'; } if (cnt == 0 || cnt > 1) cout << 'C'; else cout << ans; }
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']) p = 0 if a[0][0] * 2 <= a[1][0]: p += 1 if a[-2][0] * 2 <= a[-1][0]: p += 2 print(['C', a[0][1], a[-1][1], 'C'][p])
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() { string temp = "ABCD"; char res, a, b; int count = 0; bool check[4][2]; string choice[4]; for (int i = 0; i < 4; i++) check[i][0] = check[i][1] = 1; for (int i = 0; i < 4; i++) cin >> a >> b >> choice[i]; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { if (i != j) { check[i][0] &= (choice[i].size() >= (2) * choice[j].size()); check[i][1] &= ((2) * choice[i].size() <= choice[j].size()); } } } for (int i = 0; i < 4; i++) if (check[i][0] || check[i][1]) count++, res = temp[i]; if (count == 1) cout << res << endl; else cout << "C" << endl; return 0; }
CPP
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
import java.util.Scanner; public class CF { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String a = sc.next().substring(2); String b = sc.next().substring(2); String c = sc.next().substring(2); String d = sc.next().substring(2); String ans = "NO"; if (max(a,b,c) * 2 <= d.length() || min(a,b,c) >= d.length() * 2) { ans = "D"; } if (max(a,b,d) * 2 <= c.length() || min(a,b,d) >= c.length() * 2) { if (ans == "NO") { ans = "C"; } else { System.out.println("C"); return; } } if (max(a,c,d) * 2 <= b.length() || min(a,c,d) >= b.length() * 2) { if (ans == "NO") { ans = "B"; } else { System.out.println("C"); return; } } if (max(d,b,c) * 2 <= a.length() || min(d,b,c) >= a.length() * 2) { if (ans == "NO") { ans = "A"; } else { System.out.println("C"); return; } } if (ans != "NO") { System.out.println(ans); return; } System.out.println("C"); return; } public static int max(String a, String b, String c) { return Math.max(a.length(), Math.max(b.length(), c.length())); } public static int min(String a, String b, String c) { return Math.min(a.length(), Math.min(b.length(), c.length())); } }
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> char str[111][111]; int main() { while (scanf("%s", &str[0]) != EOF) { scanf("%s", &str[1]); scanf("%s", &str[2]); scanf("%s", &str[3]); int tot = 0, ans; for (int i = 0; i < 4; i++) { int a = 0, b = 0; for (int j = 0; j < 4; j++) { if (j == i) continue; if (strlen(str[i] + 2) >= 2 * strlen(str[j] + 2)) a++; else if (2 * strlen(str[i] + 2) <= strlen(str[j] + 2)) b++; } if (a == 4 - 1 || b == 4 - 1) tot++, ans = i; } if (tot == 1) printf("%c", str[ans][0]); 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
#include <bits/stdc++.h> using namespace std; int cnt; char k; int main() { string a, b, c, d; cin >> a >> b >> c >> d; int az = a.size() - 2, bz = b.size() - 2, cz = c.size() - 2, dz = d.size() - 2; if (az * 2 <= bz && az * 2 <= cz && az * 2 <= dz) { cnt++; k = 'A'; } if (bz * 2 <= az && bz * 2 <= cz && bz * 2 <= dz) { cnt++; k = 'B'; } if (cz * 2 <= az && cz * 2 <= bz && cz * 2 <= dz) { cnt++; k = 'C'; } if (dz * 2 <= az && dz * 2 <= bz && dz * 2 <= cz) { cnt++; k = 'D'; } if (az / 2 >= bz && az / 2 >= cz && az / 2 >= dz) { cnt++; k = 'A'; } if (bz / 2 >= az && bz / 2 >= cz && bz / 2 >= dz) { cnt++; k = 'B'; } if (cz / 2 >= az && cz / 2 >= bz && cz / 2 >= dz) { cnt++; k = 'C'; } if (dz / 2 >= az && dz / 2 >= bz && dz / 2 >= cz) { cnt++; k = 'D'; } if (cnt == 1) { cout << k; return 0; } 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
def check(a,b,c,d): if (a>=b*2 and a>=c*2 and a>=d*2) or (a*2<=b and a*2<=c and a*2<=d): return 1 else: return 0 a=len(input())-2 b=len(input())-2 c=len(input())-2 d=len(input())-2 ans=["A","B","C","D"] cnt=[check(a,b,c,d),check(b,a,c,d),check(c,a,b,d),check(d,a,b,c)] if sum(cnt)==1: for i in range(len(cnt)): if cnt[i]==1: print(ans[i]) 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 sys def minp(): return sys.stdin.readline().strip() a = [] for i in range(4): a.append(minp()) b = a[::] if len(b[2]) > len(b[3]): b[2],b[3] = b[3],b[2] if len(b[1]) > len(b[2]): b[1],b[2] = b[2],b[1] if len(b[0]) > len(b[1]): b[0],b[1] = b[1],b[0] if len(b[2]) > len(b[3]): b[2],b[3] = b[3],b[2] if len(b[1]) > len(b[2]): b[1],b[2] = b[2],b[1] if len(b[2]) > len(b[3]): b[2],b[3] = b[3],b[2] m = None M = None if len(b[0])*2 - 4 <= len(b[1])-2: m = b[0] if len(b[2])*2 - 4 <= len(b[3])-2: M = b[3] if m: if M: print('C') else: print(m[0]) else: if M: print(M[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
l=input() l=len(l)-2 l2=input() l2=len(l2)-2 l3=input() l3=len(l3)-2 l4=input() l4=len(l4)-2 m=[l,l2,l3,l4] m.sort() pp=0 if((m[1]/m[0])>=2 and (m[2]/m[0])>=2 and (m[3]/m[0])>=2): pp+=1 if((m[3]/m[0])>=2 and (m[3]/m[1])>=2 and (m[3]/m[2])>=2): pp+=1 if(pp==1): if((m[1]/m[0])>=2 and (m[2]/m[0])>=2 and (m[3]/m[0])>=2): if(m[0]==l): print('A') elif(m[0]==l2): print('B') elif(m[0]==l3): print('C') else: print('D') elif((m[3]/m[0])>=2 and (m[3]/m[1])>=2 and (m[3]/m[2])>=2 ): if(m[3]==l): print('A') elif(m[3]==l2): print('B') elif(m[3]==l3): print('C') else: print('D') else: print('C') 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 = sorted([(len(input()) - 2, i) for i in 'ABCD']) p = 0 if a[0][0] * 2 <= a[1][0]: p += 1 if a[-2][0] * 2 <= a[-1][0]: p += 2 print(['C', a[0][1], a[-1][1], 'C'][p]) # Made By Mostafa_Khaled
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
//package round250; import java.util.Scanner; public class a { public static void main(String[] args) { Scanner leer=new Scanner(System.in); int vec[]=new int[4]; int may=Integer.MIN_VALUE; int men=Integer.MAX_VALUE; int x=0,y=0; for (int i = 0; i < vec.length; i++) { vec[i]=leer.next().length()-2; if(vec[i]>may){ may=vec[i]; x=i; } //else{ if(vec[i]<men){ men=vec[i]; y=i; } //} } men=men*2; may=may/2; boolean res=false; boolean res1=false; for (int i = 0; i < vec.length; i++) { if(men>vec[i] && i!=y){res=true;break;} } for (int i = 0; i < vec.length; i++) { if(may<vec[i] && i!=x){res1=true;break;} } if(res1 && res){ System.out.println("C"); return; } if(res1==false && res==false){ System.out.println("C"); return; } int op=0; if(res){ op=x; }else{op=y;} switch (op) { 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; default: 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
from math import * from collections import * from sys import * import string import re t=stdin.readline p=stdout.write def GI(): return map(int, input().strip().split()) def GS(): return map(str, t().strip().split()) def IL(): return list(map(int, t().strip().split())) def SL(): return list(map(str, t().strip().split())) a=sorted([(len(input())-2,i) for i in 'ABCD']) c=0 if a[0][0]*2<=a[1][0]: c+=1 if a[-2][0]*2<=a[-1][0]: c+=2 print(['C',a[0][1],a[-1][1],'C'][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.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; public class TheChildAndHomework { public static void main(String[] args) throws IOException { BufferedReader f = new BufferedReader(new InputStreamReader(System.in)); int[] a = new int[4]; for (int i = 0; i < 4; i++) a[i] = f.readLine().length() - 2; ArrayList<Integer> al = new ArrayList<Integer>(); for (int i = 0; i < 4; i++) { boolean b1 = true; boolean b2 = true; for (int j = 0; j < 4; j++) if (i != j) { if (a[i] < 2*a[j]) b1 = false; if (2*a[i] > a[j]) b2 = false; } if (b1 || b2) al.add(i); } if (al.size() == 1) System.out.println((char)('A'+al.get(0))); 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
x, y = {}, {} def get_len(path): return int(len(path[1])) x['A'] = input() x['B'] = input() x['C'] = input() x['D'] = input() y = sorted(x.items(), key=get_len) if (len(y[0][1]) - 2) * 2 <= (len(y[1][1]) - 2) and (len(y[3][1]) - 2) < (len(y[2][1]) - 2) * 2: print( y[0][0] ) elif (len(y[3][1]) - 2) >= (len(y[2][1]) - 2) * 2 and (len(y[0][1]) - 2) * 2 > (len(y[1][1]) - 2): print( y[3][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
#!/usr/bin/python a=input() b=input() c=input() d=input() l=[len(a)-2,len(b)-2,len(c)-2,len(d)-2] counter=0 ans=0 for i in range(0,len(l)): f=1 for j in range(0,len(l)): if(i!=j): if(l[i]<2*l[j]): f=0 break if f==1: counter=counter+1 ans=i f=1 for j in range(0,len(l)): if(i!=j): if(2*l[i]>l[j]): f=0 break if f==1: counter=counter +1 ans=i if(counter !=1 or ans==2): print ('C') elif ans==0: print ('A') elif ans==1: print ('B') elif ans==3: 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.util.*; public class ProB { static int ans,ju,p; static String[] aa=new String[4]; static int[] bb=new int[4]; public static void main(String[] args) { Scanner in=new Scanner(System.in); for(int i=0;i<4;i++) { aa[i]=in.nextLine(); bb[i]=aa[i].length()-2; } ans=2; for(int i=0;i<4;i++) { ju=1; for(int j=0;j<4;j++) { if(j==i) continue; if(bb[i]<2*bb[j]) { ju=0;break;} } if(ju==1) { ans=i;p++;} ju=1; for(int j=0;j<4;j++) { if(j==i) continue; if(bb[i]*2>bb[j]) { ju=0;break;} } if(ju==1) { ans=i;p++;} } if(p>1) ans=2; System.out.println((char)('A'+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.util.*; public class TheChildAndHomework { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String A = sc.next(); String B = sc.next(); String C = sc.next(); String D = sc.next(); sc.close(); List<String> list = new ArrayList<>(); list.add(A); list.add(B); list.add(C); list.add(D); Collections.sort(list,new Comparator<String>(){ public int compare(String s1, String s2) { if(s1.length()<s2.length()) return -1; else if(s1.length()>s2.length()) return 1; else return 0; } }); int counter = 0; char ans = '\n'; if((list.get(0).length()-2)*2<=list.get(1).length()-2) { ans = list.get(0).charAt(0); counter++; } if((list.get(2).length()-2)*2<=list.get(3).length()-2) { ans = list.get(3).charAt(0); counter++; } if(counter == 2 || counter==0) 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
b=[] for i in range(4): s=input() b.append([len(s)-2,s[0]]) b.sort() if b[1][0]>=2*b[0][0] and b[3][0]>=2*b[2][0]:print('C') elif b[1][0]>=2*b[0][0]:print(b[0][1]) elif b[3][0]>=2*b[2][0]:print(b[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
def main(): CHOICES = ['A', 'B', 'C', 'D'] lines = [] for i in range(4): lines.append(raw_input()) # print(lines) 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
#!/usr/bin/env python #-*- coding: utf-8 -*- from collections import defaultdict from math import factorial as f from fractions import gcd as g l = [] s = raw_input () l.append (len (s) - 2) s = raw_input () l.append (len (s) - 2) s = raw_input () l.append (len (s) - 2) s = raw_input () l.append (len (s) - 2) ret = "ABCD" x = [0] * 4 if l [0] >= 2 * max (l [1], l [2], l [3]) or l [0] * 2 <= min (l [1], l [2], l [3]): x [0] = 1 if l [1] >= 2 * max (l [0], l [2], l [3]) or l [1] * 2 <= min (l [0], l [2], l [3]): x [1] = 1 if l [2] >= 2 * max (l [0], l [1], l [3]) or l [2] * 2 <= min (l [0], l [1], l [3]): x [2] = 1 if l [3] >= 2 * max (l [0], l [1], l [2]) or l [3] * 2 <= min (l [0], l [1], l [2]): x [3] = 1 if x.count (1) > 1 or x.count (1) == 0: print "C" else: print ret [x.index (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
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws Exception{ Reader.init(System.in); int size [] = new int [4] ; for(int i = 0 ; i < 4 ; i++) { size[i] = Reader.next().trim().length() - 2; } char answerl = 'C'; char answers = 'C'; int countl = 0 ; int counts = 0 ; for(int i = 0 ; i < 4 ; i++) { int longer = 0 ; int shorter = 0 ; for (int j = 0; j < 4; j++) { if(j == i) continue; if (size[i] >= size[j] * 2) longer++ ; if(size[i] * 2 <= size[j] ) shorter++ ; } if(longer == 3 ){ countl++ ; answerl = (char) (i + 'A') ; } if(shorter == 3 ){ counts++ ; answers = (char) (i + 'A') ; } } if(countl == 1 && counts == 1) System.out.println("C");else if(countl == 1) System.out.println(answerl);else if(counts == 1) System.out.println(answers); else System.out.println("C"); } } class pair implements Comparable<pair> { long a , b ; pair(long a , long b) { this.a = a ; this.b = b ; } public int compareTo(pair t) { if(t.b > b) return -1 ; if(t.b < b) return 1 ; return 0 ; } } class Reader { static BufferedReader reader; static StringTokenizer tokenizer; static void init(InputStream input) { reader = new BufferedReader( new InputStreamReader(input) ); tokenizer = new StringTokenizer(""); } static String next() throws IOException { while ( ! tokenizer.hasMoreTokens() ) { tokenizer = new StringTokenizer( reader.readLine() ); } return tokenizer.nextToken(); } static int nextInt() throws IOException { return Integer.parseInt( next() ); } static int nextShort() throws IOException { return Short.parseShort(next() ); } static double nextDouble() throws IOException { return Double.parseDouble( next() ); } static long nextLong() throws IOException{ return Long.parseLong(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
# your code goes here i=0 a=[] choice=['A','B','C','D'] for j in xrange(4): line=raw_input() a.append([line.split('.')[1],len(line.split('.')[1]),choice[i]]) i+=1 choices={} defaulter={} for x in a: for y in a: if x[2]==y[2]: continue else: if 2*y[1]<=x[1]: if not defaulter.has_key(x[2]): if choices.has_key(x[2]): if choices[x[2]]=='L': continue else: choices.pop(x[2],None) defaulter[x[2]]=1 elif not choices.has_key(x[2]): choices[x[2]]='L' else: continue elif 2*x[1]<=y[1]: if not defaulter.has_key(x[2]): if choices.has_key(x[2]): if choices[x[2]]=='S': continue else: choices.pop(x[2],None) defaulter[x[2]]=1 elif not choices.has_key(x[2]): choices[x[2]]='S' else: continue else: choices.pop(x[2],None) defaulter[x[2]]=1 if len(choices)>=2 or len(choices)==0: print 'C' else: for i in choices: print i
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.BufferedReader; import java.io.OutputStream; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.io.Reader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * @author Vadim */ public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); PrintWriter out = new PrintWriter(outputStream); TaskA solver = new TaskA(); solver.solve(1, in, out); out.close(); } } class TaskA { public void solve(int testNumber, InputReader in, PrintWriter out) { String a = in.readLine(); String b = in.readLine(); String c = in.readLine(); String d = in.readLine(); int l[] = new int[] {a.length()-2, b.length()-2, c.length()-2, d.length()-2}; int ans = 0; int count = 0; for (int i = 0; i < 4; i++) { boolean more = true; boolean less = true; for (int j = 0; j < 4; j++) { if(i!=j) { if(l[i] < 2*l[j]) { more = false; } } } for (int j = 0; j < 4; j++) { if(i!=j) { if(2*l[i] > l[j]) { less = false; } } } if(more || less) { ans = i; count++; } } if(count == 1) { out.println((char)('A'+ans)); } else { out.println("C"); } } } class InputReader extends BufferedReader { public InputReader(InputStream st) { super(new InputStreamReader(st)); } public String readLine() { try { return super.readLine(); } catch (IOException e) { return null; } } }
JAVA
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
list,temp=[],[] for i in range(4): a=input() list.append(len(a)-2) temp=list.copy() temp.sort() if(2*temp[0]<=temp[1] and temp[3]<(2*temp[2])): ind=list.index(temp[0]) print(chr(65+ind)) elif(temp[3]>=(2*temp[2]) and 2*temp[0]>temp[1]): ind=list.index(temp[3]) print(chr(65+ind)) 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
c=sorted([(len(raw_input())-2,i) for i in range(4)]) s,l=c[0][0]*2<=c[1][0],c[2][0]*2<=c[3][0] print 'C' if not s^l else chr(c[l*3][1]+65)
PYTHON
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
import sys from bisect import insort lines = [] letter_map = {0: "A", 1: "B", 2: "C", 3: "D"} for i in xrange(4): insort(lines, (len(sys.stdin.readline().strip()[2:]), i)) lower = 2*lines[0][0] <= lines[1][0] higher = 2*lines[2][0] <= lines[3][0] if lower and higher: print "C" elif lower: print letter_map[lines[0][1]] elif higher: print letter_map[lines[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
s=[] for _ in range(4): t=list(input()) s.append(len(t)-2) p=s[:] d=["A","B","C","D"] s.sort() sw=0 sw2=0 if s[1] >= 2 * s[0]: sw = 1 if s[3] >= 2 * s[2]: sw2 = 1 if sw and not sw2: print(d[p.index(s[0])]) elif sw2 and not sw: print(d[p.index(s[3])]) 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
def condition(t, s1, s2, s3): n1, n2, n3, n4 = len(t[2:]), len(s1[2:]), len(s2[2:]), len(s3[2:]) if n1 >= 2 * n2 and n1 >= 2 * n3 and n1 >= 2 * n4: return True elif 2 * n1 <= n2 and 2 * n1 <= n3 and 2 * n1 <= n4: return True return False def homework(lst): x1 = condition(lst[0], lst[1], lst[2], lst[3]) x2 = condition(lst[1], lst[0], lst[2], lst[3]) x3 = condition(lst[2], lst[1], lst[0], lst[3]) x4 = condition(lst[3], lst[1], lst[2], lst[0]) if x1 and not x2 and not x3 and not x4: return "A" elif x2 and not x1 and not x3 and not x4: return "B" elif x3 and not x1 and not x2 and not x4: return "C" elif x4 and not x1 and not x2 and not x3: return "D" return "C" a = list() for i in range(4): s = input() a.append(s) print(homework(a))
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.math.*; import java.text.*; import java.io.*; import java.awt.Point; import static java.util.Arrays.*; import static java.lang.Integer.*; import static java.lang.Double.*; import static java.lang.Long.*; import static java.lang.Short.*; import static java.lang.Math.*; import static java.math.BigInteger.*; import static java.util.Collections.*; public class Main { // IO Imports private BufferedReader in; private StringTokenizer st; private PrintWriter out; // Pretty Stuff private DecimalFormat fmt = new DecimalFormat("0.0000000000"); public void solve() throws Exception { int[] count = new int[4]; for (int i=0; i<4; i++) { int num = in.readLine().length() - 2; count[i] = num; } int ans = -1; for (int i=0; i<4; i++) { int testNum = count[i]; int greater = 0; int less = 0; for (int j=0; j<4; j++) { if (j != i) { if (testNum * 2 <= count[j]) { greater ++; } if (testNum/2 >= count[j]) { less ++; } } } if ((greater == 3 || less == 3)) { if (ans == -1) ans = i; else { out.println("C"); return; } } } if (ans == -1) { out.println("C"); return; } out.println((char) ('A' + ans)); } public Main() { this.in = new BufferedReader(new InputStreamReader(System.in)); this.out = new PrintWriter(System.out); } public void end() { try { this.out.flush(); this.out.close(); this.in.close(); } catch (Exception e){ //do nothing then :) } } public static void main(String[] args) throws Exception { Main solver = new Main(); solver.solve(); solver.end(); } }
JAVA
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
#include <bits/stdc++.h> using namespace std; int main() { string a, b, c, d; cin >> a >> b >> c >> d; char ans = '*'; int la = a.length() - 2, lb = b.length() - 2, lc = c.length() - 2, ld = d.length() - 2; if ((la >= 2 * lb && la >= 2 * lc && la >= 2 * ld) || ((la * 2 <= lb && la * 2 <= lc && la * 2 <= ld))) { if (ans == '*') ans = 'A'; else ans = '#'; } if ((lb >= 2 * la && lb >= 2 * lc && lb >= 2 * ld) || ((lb * 2 <= la && lb * 2 <= lc && lb * 2 <= ld))) { if (ans == '*') ans = 'B'; else ans = '#'; } if ((lc >= 2 * lb && lc >= 2 * la && lc >= 2 * ld) || ((lc * 2 <= lb && lc * 2 <= la && lc * 2 <= ld))) { if (ans == '*') ans = 'C'; else ans = '#'; } if ((ld >= 2 * lb && ld >= 2 * lc && ld >= 2 * la) || ((ld * 2 <= lb && ld * 2 <= lc && ld * 2 <= la))) { if (ans == '*') ans = 'D'; else ans = '#'; } if (ans != '*' && ans != '#') cout << ans << 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
a = len( str( raw_input() ) ) - 2 b = len( str( raw_input() ) ) - 2 c = len( str( raw_input() ) ) - 2 d = len( str( raw_input() ) ) - 2 ans = [0] * 4 if ( a >= b * 2 ) and ( a >= c * 2 ) and ( a >= d * 2 ): ans[0] += 1 if ( b >= a * 2 ) and ( b >= c * 2 ) and ( b >= d * 2 ): ans[1] += 1 if ( c >= a * 2 ) and ( c >= b * 2 ) and ( c >= d * 2 ): ans[2] += 1 if ( d >= a * 2 ) and ( d >= b * 2 ) and ( d >= c * 2 ): ans[3] += 1 if ( a <= b / 2 ) and ( a <= c / 2 ) and ( a <= d / 2 ): ans[0] += 1 if ( b <= a / 2 ) and ( b <= c / 2 ) and ( b <= d / 2 ): ans[1] += 1 if ( c <= a / 2 ) and ( c <= b / 2 ) and ( c <= d / 2 ): ans[2] += 1 if ( d <= a / 2 ) and ( d <= b / 2 ) and ( d <= c / 2 ): ans[3] += 1 if ( sum( ans ) <> 1 ): print "C" else: for i in range(4): if ( ans[i] == 1 ): if ( i == 0 ): print "A" elif ( i == 1): print "B" elif ( i == 2 ): print "C" elif ( i == 3 ): print "D"
PYTHON
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
if __name__ == '__main__': s = list() for _ in range(4): s.append(len(input()) - 2) l = sorted(s) mn, mx = l[0], l[3] mn = l[0] if l[0] <= l[1] / 2 else 0 mx = l[3] if l[3] >= l[2] * 2 else 0 if not mn and mx: print(chr(s.index(mx) + ord("A"))) elif mn and not mx: print(chr(s.index(mn) + ord("A"))) 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 z=new Scanner(System.in); int[] a=new int[4]; for(int i=0;i<a.length;i++) a[i]=z.nextLine().length()-2; int k1=0; String x=""; for(int i=0;i<a.length;i++){ int k=0; int p=0; for(int j=0;j<a.length;j++){ if(j!=i){ if(a[i]>=2*a[j]) k++; } } for(int j=0;j<a.length;j++){ if(j!=i){ if(a[i]<=a[j]/2) p++; } } if(k==3 || p==3){ x+=Integer.toString(i); } } if(x.length()==1){ if(Integer.parseInt(x)==0){ System.out.println("A"); } else if(Integer.parseInt(x)==1){ System.out.println("B"); } else if(Integer.parseInt(x)==2){ System.out.println("C"); } else if(Integer.parseInt(x)==3){ System.out.println("D"); } } else System.out.println("C"); z.close(); } }
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
cs = [raw_input() for _ in range(4)] cs.sort(key=len) f = lambda x: len(x)-2 t = 0 if 2*f(cs[0]) <= f(cs[1]): ans = cs[0][0] t += 1 if f(cs[3]) >= 2*f(cs[2]): ans = cs[3][0] t += 1 if t == 0 or t == 2: ans = 'C' print ans
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 = [] a.append(len(input())-2) a.append(len(input())-2) a.append(len(input())-2) a.append(len(input())-2) great = [] for i in range(4): temp = a[i] shor = True lon = True for j in range(4): if i!= j and a[i]<2*a[j]: lon = False if i!= j and a[i]>a[j]//2: shor = False if lon or shor: great.append(i) if len(great)==1: print(chr(great[0]+ord('A'))) 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=input() s2=input() s3=input() s4=input() l1=len(s1)-2 l2=len(s2)-2 l3=len(s3)-2 l4=len(s4)-2 l=[l1,l2,l3,l4] i=l.index(min(l)) r=l.index(max(l)) c1=0 j=0 while j<4: if j!=i: if l[i]<=l[j]//2: j=j+1 else: c1=1 break else: j=j+1 c2=0 j=0 while j<4: if j!=r: if l[r]>=l[j]*2: j=j+1 else: c2=1 break else: j=j+1 if c1==0 and c2==1: if i==0: print('A') elif i==1: print('B') elif i==2: print('C') elif i==3: print('D') elif c1==1 and c2==0: if r==0: print('A') elif r==1: print('B') elif r==2: print('C') elif r==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
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.Locale; import java.util.StringTokenizer; public class B_250 { static StringTokenizer st; static BufferedReader br; static PrintWriter pw; public static void main(String[] args) throws IOException { Locale.setDefault(Locale.US); br = new BufferedReader(new InputStreamReader(System.in)); pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter( System.out))); int ind = 0; String str[] = new String[5]; int ans[] = new int[5]; for (int i = 1; i <= 4; i++) { str[i] = next(); ans[i] = str[i].length() - 2; } boolean f = false; for (int i = 1; i <= 4; i++) { boolean d = false, l = false; int k = 0, p = 0; for (int j = 1; j <= 4; j++) { if (i != j) { if ((ans[i] * 2 <= ans[j])) k++; if (ans[i] >= ans[j] * 2) p++; } } if (k == 3 || p == 3) { ind = i; if (!f) f = true; else { System.out.println("C"); return; } } } pw.print(ind == 0 ? "C" : (char) (ind + 64)); pw.close(); } private static int nextInt() throws IOException { return Integer.parseInt(next()); } private static long nextLong() throws IOException { return Long.parseLong(next()); } private static double nextDouble() throws IOException { return Double.parseDouble(next()); } private static String next() throws IOException { while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine()); 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
import java.io.*; public class Main { public static void main(String args[]) throws java.lang.Exception { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); String[] A=new String[4]; int[] B=new int[4]; String s; int k=0; for(int i=0;i<4;i++) { A[i]=br.readLine(); k=A[i].indexOf("."); B[i]=A[i].length()-(k+1); } Solve(B,A); } static void Solve(int[] B,String[] A) { int less=0,great=0; less=Lesser(B); great=Greater(B); //System.out.println("less "+less+" great "+great); if((less!=-1&&great!=-1)||(less==-1&&great==-1)) System.out.println("C"); else { if(less!=-1) System.out.println(A[less].charAt(0)); else System.out.println(A[great].charAt(0)); } } static int Lesser(int[] B) { int len=B.length; boolean ret=false; for(int i=0;i<len;i++) { //System.out.println("less"); ret=true; for(int j=0;j<len;j++) if(j!=i&&B[i]>(B[j]/2)) { ret=false; break; } if(ret) return i; } return -1; } static int Greater(int[] B) { int len=B.length; boolean ret=false; for(int i=0;i<len;i++) { //System.out.println("great"); ret=true; for(int j=0;j<len;j++) if(j!=i&&B[i]<(2*B[j])) { ret=false; break; } if(ret) return i; } return -1; } }
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 Cf { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); //String q[] = br.readLine().split(" "); //int k = Integer.parseInt(q[0]); //int d = Integer.parseInt(q[1]); //String s[] = br.readLine().split(" "); //int a[] = new int[10]; //for(int i=0;i<n;i++) // a[i] = Integer.parseInt(s[i]); int a = br.readLine().length()-2; int b = br.readLine().length()-2; int c = br.readLine().length()-2; int d = br.readLine().length()-2; int small=a;char cs='A'; if(b<small){ small=b;cs='B';} if(c<small){ small=c;cs='C';} if(d<small){ small=d;cs='D';} int big=a; char cb='A'; if(b>big){ big=b;cb='B';} if(c>big){ big=c;cb='C';} if(d>big){ big=d;cb='D';} char ans = 'C';int sc=0;int found = 0; if(2*small<=a)sc++;if(2*small<=b)sc++;if(2*small<=c)sc++;if(2*small<=d)sc++; if(sc==3){found++;ans=cs;} int bc=0; if(big>=2*a)bc++;if(big>=2*b)bc++;if(big>=2*c)bc++;if(big>=2*d)bc++; if(bc==3){found++;ans=cb;} if(found==1) System.out.println(ans); else System.out.println("C"); // end of main } }
JAVA
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
l = [len(input()) - 2 for _ in range(4)] res = [] for i in range(4): if 2 * l[i] <= min(l[:i] + l[i+1:]) or l[i] >= 2 * max(l[:i] + l[i + 1:]): res.append(i) print("ABCD"[res[0] if len(res) == 1 else 2])
PYTHON3
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
#include <bits/stdc++.h> using namespace std; const int inf = ~0U >> 1; const int MOD = int(1e9) + 7; const double EPS = 1e-6; char s[4][120]; int i, j, ans = -1; int main() { int a[4], cnt = 0; char b[4] = {'A', 'B', 'C', 'D'}; for (i = (0); i <= (3); i++) { scanf("%s", s[i]); a[i] = strlen(s[i]) - 2; } for (i = (0); i <= (3); i++) { int f1, f2; f1 = f2 = 1; for (j = (0); j <= (3); j++) { if (j == i) continue; if (2 * a[i] > a[j]) f1 = 0; if (a[i] < 2 * a[j]) f2 = 0; } if (f1 || f2) cnt++, ans = i; } if (ans != -1 && cnt == 1) cout << b[ans] << endl; else cout << 'C' << endl; return 0; }
CPP
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
#include <bits/stdc++.h> using namespace std; int main() { string a[4]; for (int i = 0; i < 4; i++) cin >> a[i]; int l[4]; for (int i = 0; i < 4; i++) l[i] = a[i].length() - 2; char c; int sum = 0; for (int i = 0; i < 4; i++) { int sumshort = 0, sumtall = 0; for (int j = 0; j < 4; j++) { if (j != i) { if (l[i] * 2 <= l[j]) sumshort++; if (l[i] >= l[j] * 2) sumtall++; } } if (sumshort == 3 && sumtall == 0) { c = a[i][0]; sum++; } if (sumtall == 3 && sumshort == 0) { c = a[i][0]; sum++; } } if (sum == 1) cout << c << 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
def compare_with_front_element(v,pos): return v[pos+1][2]/v[pos][2]>=2 def child_choice(v): v.sort(key=lambda x:x[2]) wonderful_list=[] if compare_with_front_element(v,0): wonderful_list.append(v[0][0]) if compare_with_front_element(v,2): wonderful_list.append(v[3][0]) if len(wonderful_list)==1: return wonderful_list[0] return 'C' v=[] for c in range(4): var,t=input().split('.') v.append((var,t,len(t))) print(child_choice(v))
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.Scanner; public class TheChildAndHomework { public static void main(String[] args) { Scanner in=new Scanner(System.in); String A=in.next(); String B=in.next(); String C=in.next(); String D=in.next(); A=A.substring(2); B=B.substring(2); C=C.substring(2); D=D.substring(2); int a=A.length(); int b=B.length(); int c=C.length(); int d=D.length(); int AA[]={a,b,c,d}; int count=0; int count2=0; String res=""; ArrayList<Integer> l=new ArrayList<>(); for (int i = 0; i < 4; i++) { count=0; count2=0; for (int j = 0; j < 4; j++) { int f=AA[i]; int f1=AA[j]/2; int f3=AA[j]*2; if (f<=f1) { count++; if(count==3) { l.add(i); } } if (f>=f3) { count2++; if(count2==3) { l.add(i); } } } } if (l.isEmpty()||l.size()>1) { System.out.println("C"); } else { if (l.get(0)==0) { System.out.println("A"); } else if (l.get(0)==1) { System.out.println("B"); } else if (l.get(0)==2) { System.out.println("C"); } else if (l.get(0)==3) { 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
s = [] length = [0] * 4 for i in range(4): s.append(input().rstrip()) s[i] = s[i][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
#include <bits/stdc++.h> #pragma GCC optimize("O3") using ll = long long int; using namespace std; using vec = vector<int>; int main() { string s; vec v(4); for (int i = 0; i < 4; i++) { cin >> s; v[i] = s.size() - 2; } bool a = false, b = false; int ind = -1; string choice = "ABCD"; int cnt = 0; for (int i = 0; i < 4; i++) { a = true, b = true; for (int j = 0; j < 4; j++) { if (i == j) continue; if (v[j] * 2 > v[i]) a = false; if (v[j] < v[i] * 2) b = false; } if (a ^ b) { ind = i; cnt++; } } if (cnt == 1) printf("%c\n", char(choice[ind])); else puts("C"); return 0; }
CPP
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
d = {} ans = 0 cnt = 0 for i in range(4): x = list(input().split(".")) d[x[0]] = len(x[1]) for x in d.keys(): flag = True for y in d.keys(): if d[x] > (d[y]/2) and (x != y): flag = False if flag: ans = x cnt += 1 for x in d.keys(): flag = True for y in d.keys(): if d[x] < (d[y]*2) and (x != y): flag = False if flag: ans = x cnt += 1 if cnt != 1: print("C") else: 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
varianti=[input()[2:] for i in range(4)] lenz=[len(varianti[i]) for i in range(4)] counter=0 for i in range(4): dub=lenz[:] now=dub.pop(i) c1=0 c2=0 for z in range(3): if(now/dub[z]>=2): c1+=1 elif (dub[z]/now>=2): c2+=1 if c1==3 or c2==3 : zamechat=i counter+=1 if counter==1: print(['A','B','C','D'][zamechat]) 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=raw_input() b=raw_input() c=raw_input() d=raw_input() v=[] v+=[(len(a)-2,'A')] v+=[(len(b)-2,'B')] v+=[(len(c)-2,'C')] v+=[(len(d)-2,'D')] v.sort() #print v f=0 if(2*v[0][0]<=v[1][0]): if((v[3][0]>=2*v[2][0])): print 'C' f=1 else: f=1 print v[0][1] elif((v[3][0]>=2*v[2][0])): print v[3][1] f=1 if(f==0): 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() { char a, b; string s[4]; int l[4]; int mn = 2147483647, mx = 0; int q = 0, w = 0; for (int i = 0; i < 4; i++) { cin >> a >> b; cin >> s[i]; l[i] = s[i].size(); if (mn > l[i]) { mn = l[i]; q = i; } if (mx < l[i]) { mx = l[i]; w = i; } } int f1 = 0, f2 = 0; int k = 0; for (int i = 0; i < 4; i++) { if (mn > l[i] / 2 && i != q) { f1 = 1; } if (mx < 2 * l[i] && i != w) { f2 = 1; } } if (f1 ^ f2) { if (f1) k = w; else k = q; cout << char(k + 'A'); return 0; } 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
choice=[] for i in range(4): choice.append(len(input(' ')[2:])) Shortest=True Longest=True cc=0 ci=None for i in range(4): Shortest=True Longest=True for j in range(4): if i==j:continue if choice[i]<choice[j]*2:Longest=False if choice[i]*2>choice[j]:Shortest=False if Shortest:cc+=1;ci=chr(65+i) if Longest:cc+=1;ci=chr(65+i) if cc==1: print(ci) 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
# 437A # The Child and Homework choices = ('A', 'B', 'C', 'D') counts = list() counts.append(len(raw_input()) - 2) counts.append(len(raw_input()) - 2) counts.append(len(raw_input()) - 2) counts.append(len(raw_input()) - 2) result = -1 for i in range(4): valid = True oldDiv = -1 for j in range(4): if i == j: continue div = counts[i] / float(counts[j]) if div < 0.5: div = 0.5 elif div > 2.0: div = 2.0 if oldDiv == -1: oldDiv = div if oldDiv != div or (div > 0.5 and div < 2.0): valid = False break if valid and result >= 0: result = 2 break elif valid: result = i if result == -1: result = 2 print choices[result]
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.*; import java.io.*; public class A { public static void main(String[] args) { new A().solve(); } public void solve() { Scanner in = new Scanner(System.in); String[] s = new String[4]; char[] alpha = {'A', 'B', 'C', 'D'}; for (int i = 0; i < 4; i++) s[i] = in.nextLine().substring(2); boolean[] b = new boolean[4]; for (int i = 0; i < s.length; i++) { boolean f = true; for (int j = 0; j < s.length; j++) { if (i == j) continue; if (s[i].length() < s[j].length() * 2) f = false; } if (f) { b[i] = true; continue; } f = true; for (int j = 0; j < s.length; j++) { if (i == j) continue; if (s[i].length() > s[j].length() / 2) f = false; } if (f) { b[i] = true; } } int cnt = 0; for (boolean bb : b) if (bb) cnt++; if (cnt != 1) { System.out.println('C'); return; } for (int i = 0; i < 4; i++) if (b[i]) System.out.println(alpha[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
import java.io.*; import java.util.*; public class Main { public static void main (String[] args) throws Exception { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); int[] len = new int[4]; boolean[] posib = new boolean[4]; for (int i = 0; i < 4; i++) { len[i] = in.readLine().length()-2; } for (int i = 0; i < 4; i++) { boolean doubleL = true, doubleS = true; for (int j = 0; j < 4; j++) { if(i!=j && 2*len[j]>len[i]) { doubleL = false; } if(i!=j && 2*len[i] > len[j]) { doubleS = false; } } posib[i] = doubleL || doubleS; } int ans = -1; for (int i = 0; i < 4; i++) { if(posib[i] && ans == -1) { ans = i; } else if(posib[i] && ans!=-1) { ans = 2; } } if(ans==-1) ans = 2; System.out.println((char)('A'+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
#include <bits/stdc++.h> using namespace std; string s[4]; string ss = "ABCD", ans; int r = 0, t = 0, n[4], c = 0; int main() { for (int i = 0; i < 4; i++) { cin >> s[i]; n[i] = s[i].size() - 2; } for (int i = 0; i < 4; i++) { r = 0, t = 0; for (int j = 0; j < 4; j++) { if (i != j) { if (n[i] >= 2 * n[j]) r++; if (n[i] <= n[j] / 2) t++; } } if (r == 3 || t == 3) { c++; ans = ss[i]; } } if (c == 1) cout << ans; else cout << 'C'; return 0; }
CPP
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
a = list(input()) a.pop(0) a.pop(0) b = list(input()) b.pop(0) b.pop(0) c = list(input()) c.pop(0) c.pop(0) d = list(input()) d.pop(0) d.pop(0) list1 = [b,c,d] list2 = [a,c,d] list3 = [a,b,c] list4 = [a,b,d] empty = [] temp = 1 count = 0 count1 = 0 count2 = 0 for i in range(len(list1)): if len(a) >= len(list1[i])*2 : count1+=1 continue if len(a)<=len(list1[i])/2: count2+=1 continue else: count+=1 temp = 0 break if temp == 1 and (count1 == 3 or count2 == 3): empty.append('A') count1 = 0 count2 = 0 temp = 1 for i in range(len(list2)): if len(b) >= len(list2[i])*2 : count1+=1 continue if len(b)<=len(list2[i])/2 : count2+=1 continue else: count+=1 temp = 0 break if temp == 1 and (count1 == 3 or count2 == 3): empty.append('B') count1 = 0 count2 = 0 temp = 1 for i in range(len(list3)): if len(d) >= len(list3[i])*2 : count1+=1 continue elif len(d)<=len(list3[i])/2: count2+=1 continue else: count+=1 temp = 0 break if temp == 1 and (count1 == 3 or count2 == 3): empty.append('D') count1 = 0 count2 = 0 temp = 1 for i in range(len(list4)): if len(c) >= len(list4[i])*2 : count1+=1 continue if len(a)<=len(list4[i])/2: count2+=1 continue else: count+=1 temp = 0 break if temp == 1 and (count1==3 or count2 == 3): empty.append('C') if len(empty) > 1 or len(empty) == 0: print('C') else: print(empty[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
x = [] x.append((len(input())-2, 'A')) x.append((len(input())-2, 'B')) x.append((len(input())-2, 'C')) x.append((len(input())-2, 'D')) x.sort() if x[0][0] * 2 <= x[1][0] and x[2][0] * 2 <= x[3][0]: print('C') else: if x[0][0] * 2 <= x[1][0]: print(x[0][1]) else: if x[2][0] * 2 <= x[3][0]: print(x[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
""" Codeforces Round 250 Div 2 Problem A Author : chaotic_iak Language: Python 3.3.4 """ class IOHandlerObject(object): def getInput(self, mode=2): # 0: String # 1: List of strings # 2: List of integers inputs = input().strip() if mode == 0: return inputs if mode == 1: return inputs.split() if mode == 2: return [int(x) for x in inputs.split()] def writeOutput(self, s="\n"): if isinstance(s, list): s = " ".join(s) print(s) IOHandler = IOHandlerObject() g = IOHandler.getInput w = IOHandler.writeOutput ############################## SOLUTION ############################## a,b,c,d = g(0),g(0),g(0),g(0) r = [(len(a)-2,0), (len(b)-2,1), (len(c)-2,2), (len(d)-2,3)] r.sort() t = -1 if r[0][0]*2 <= r[1][0]: t = r[0][1] if r[3][0] >= r[2][0] * 2: if not t+1: t = r[3][1] else: t = 5 if t == -1 or t == 5: print("C") else: print(chr(65+t))
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() a1=len(a)-2 b1=len(b)-2 c1=len(c)-2 d1=len(d)-2 v=[a1,b1,c1,d1] p=[] god=[] for i in range(4): k=[] for j in range(4): if i!=j: k.append(v[i]/v[j]) p.append(k) for i in range(4): t=0 k=0 for j in range(3): if p[i][j]>=2: t=t+1 elif p[i][j]<=0.5: k+=1 if (k==0 and t==3) or (t==0 and k==3): if i==0: god.append('A') elif i==1: god.append('B') elif i==2: god.append('C') else: god.append('D') if len(god)==1: print(god[0]) else: print('C')
PYTHON3
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
#include <bits/stdc++.h> using namespace std; int main() { string s; int a[4]; char rez; int r = 0; for (int k = 0; k < 4; k++) { cin >> s; a[k] = s.size() - 2; } for (int k = 0; k < 4; k++) { int shorter = 0, longer = 0; for (int i = 0; i < 4; i++) { if (k != i) { if (a[k] * 2 <= a[i]) { shorter++; } if (a[k] >= 2 * a[i]) { longer++; } } } char c = 'A' + k; if (shorter == 3) { rez = c; r++; } else if (longer == 3) { rez = c; r++; } } if (r == 1) { cout << rez << 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; const int INF = 0x3f3f3f3f; const int MV = 300008; const int ME = 2000006; const int MOD = 1000000007; char str[7][1000]; int a[7]; int main() { while (~scanf("%s", str[0])) { for (int i = 1; i < 4; i++) scanf("%s", str[i]); for (int i = 0; i < 4; i++) { a[i] = strlen(str[i]) - 2; } int tmin, tmax, tminid, tmaxid; tmin = tmax = a[0]; tminid = tmaxid = 0; for (int i = 0; i < 4; i++) { if (a[i] < tmin) { tmin = a[i]; tminid = i; } if (a[i] > tmax) { tmax = a[i]; tmaxid = i; } } sort(a, a + 4); int flag = 0; if (a[0] * 2 <= a[1]) flag++; if (a[2] * 2 <= a[3]) flag++; if (flag == 0 || flag == 2) { puts("C"); } else { int ans = 0; if (a[0] * 2 <= a[1]) { ans = tminid; } if (a[2] * 2 <= a[3]) { ans = tmaxid; } printf("%c\n", ans + 'A'); } } 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.util.StringTokenizer; public class CodeForce_250A { public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String a = in.readLine(); String b = in.readLine(); String c = in.readLine(); String d = in.readLine(); int aLen = a.length()-2; int bLen = b.length()-2; int cLen = c.length()-2; int dLen = d.length()-2; System.out.println(getResult(aLen, bLen, cLen, dLen)); } private static String getResult(int a, int b, int c, int d) { int count=0; String result=""; if((a>=2*b&&a>=2*c&&a>=2*d)||(2*a<=b&&2*a<=c&&2*a<=d)){ count++; result = "A"; } if((b>=2*a&&b>=2*c&&b>=2*d)||(2*b<=a&&2*b<=c&&2*b<=d)){ count++; result = "B"; } if((c>=2*a&&c>=2*b&&c>=2*d)||(2*c<=a&&2*c<=b&&2*c<=d)){ count++; result = "C"; } if((d>=2*a&&d>=2*b&&d>=2*c)||(2*d<=a&&2*d<=b&&2*d<=c)){ count++; result = "D"; } if(count==1) { return result; } return "C"; } }
JAVA
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
s1=input() s2=input() s3=input() s4=input() x1=len(s1)-2; x2=len(s2)-2; x3=len(s3)-2; x4=len(s4)-2; a=[] a.append((x1,1)) a.append((x2,2)) a.append((x3,3)) a.append((x4,4)) d={1:"A",2:"B",3:"C",4:"D"} a.sort() f1=0 f2=0 if((a[0][0]<=a[1][0]//2 and a[0][0]<=a[2][0]//2 and a[0][0]<=a[3][0]//2)): f1=1 if((a[3][0]>=a[0][0]*2 and a[3][0]>=a[1][0]*2 and a[3][0]>=a[2][0]*2)): f2=1 if(f1==1 and f2==0): print(d[a[0][1]]) elif(f1==0 and f2==1): print(d[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() a = a[2:] flag = 0 b = b[2:] c = c[2:] d = d[2:] a = len(a) b = len(b) c = len(c) d = len(d) ans = [] ans.append((a, 'A')) ans.append((b, 'B')) ans.append((c, 'C')) ans.append((d, 'D')) ans.sort() answer = [] if ans[1][0] / ans[0][0] >= 2: answer.append(ans[0][1]) if ans[3][0] / ans[2][0] >= 2: answer.append(ans[3][1]) if len(answer) == 1: print(*answer) 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
def solve(q): l = [len(x) for x in q] g = [] for i in range(4): f = True for j in range(4): if i == j: continue if l[i]*2 > l[j]: f = False if f: g.append(i) continue f = True for j in range(4): if i == j: continue if l[i] < l[j]*2: f = False if f: g.append(i) continue if len(g) == 1: return g[0] return 2 q = [raw_input()[2:] for i in range(4)] print chr(ord('A')+solve(q))
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; vector<string> split(const string &, char); vector<string> &split(const string &, char, vector<string> &); bool compare(int, int); int main() { vector<int> length, sorting; vector<string>::iterator it; vector<int>::iterator init; int i, decide = 0; string test; for (i = 0; i < 4; i++) { getline(cin, test); vector<string> tmp = split(test, '.'); it = tmp.begin() + 1; length.push_back((*it).size()); sorting.push_back((*it).size()); } sort(sorting.begin(), sorting.begin() + 4, compare); if (((*(sorting.begin() + 1)) * 2 <= *(sorting.begin())) && ((*(sorting.begin() + 2)) < *(sorting.begin() + 3) * 2)) { for (decide = 0, init = length.begin(); init != length.end(); init++, decide++) { if (*(init) == *(sorting.begin())) { cout << (char)(65 + decide); } } } else if (((*(sorting.begin() + 2)) >= *(sorting.begin() + 3) * 2) && ((*(sorting.begin() + 1)) * 2 > *(sorting.begin()))) { for (decide = 0, init = length.begin(); init != length.end(); init++, decide++) { if (*(init) == *(sorting.begin() + 3)) { cout << (char)(65 + decide); } } } else { cout << "C"; } } vector<string> split(const string &s, char delim) { vector<string> elems; split(s, delim, elems); return elems; } vector<string> &split(const string &s, char delim, vector<string> &elems) { stringstream ss(s); string item; while (getline(ss, item, delim)) { elems.push_back(item); } return elems; } bool compare(int a, int b) { return a > b; }
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=[] b=[] x=[] for i in range(4): a.append(input()) b.append(a[i][2:]) x.append(len(b[i])) f1=int(0) f2=int(0) for i in range(4): if(i!=x.index(max(x))): if(2*x[i]<=max(x)): f1=1 else: f1=0 break for i in range(4): if(i!=x.index(min(x))): if(x[i]>=2*min(x)): f2=1 else: f2=0 break if((f1==1 and f2==1 )or(f1==0 and f2==0)): print('C') else: print(a[x.index(max(x))][0]) if(f1==1) else print(a[x.index(min(x))][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; int main() { char a; int k = 0; string A, B, C, D; cin >> A >> B >> C >> D; int aa, bb, cc, dd; aa = A.length() - 2; bb = B.length() - 2; cc = C.length() - 2; dd = D.length() - 2; if ((2 * aa <= bb && 2 * aa <= cc && 2 * aa <= dd) || (aa >= 2 * bb && aa >= 2 * cc && aa >= 2 * dd)) { a = 'A'; k++; } if ((2 * bb <= aa && 2 * bb <= cc && 2 * bb <= dd) || (bb >= 2 * aa && bb >= 2 * cc && bb >= 2 * dd)) { a = 'B'; k++; } if ((2 * cc <= aa && 2 * cc <= bb && 2 * cc <= dd) || (cc >= 2 * aa && cc >= 2 * bb && cc >= 2 * dd)) { a = 'C'; k++; } if ((2 * dd <= aa && 2 * dd <= bb && 2 * dd <= cc) || (dd >= 2 * aa && dd >= 2 * bb && dd >= 2 * cc)) { a = 'D'; k++; } if (k == 1) cout << a << endl; else cout << 'C' << endl; }
CPP
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
import java.util.*; public class A1 { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sca=new Scanner(System.in); int ai[]=new int[5]; int bi[]=new int[5]; while(sca.hasNext()){ for(int i=1;i<=4;i++){ ai[i]=sca.next().length()-2; bi[i]=i; } for(int i=1;i<=4;i++){ int min=ai[i];int index=i; for(int j=i+1;j<=4;j++){ if(min>ai[j]){ min=ai[j]; index=j; } } int a1=ai[index]; int a2=bi[index]; ai[index]=ai[i]; bi[index]=bi[i]; ai[i]=a1; bi[i]=a2; } // for(int i=1;i<=4;i++){ // System.out.println(ai[i]); // } // System.out.println(ai[1]*2); int sum=0;int ind=-1; if(ai[1]*2<=ai[2]){ sum++; ind=1; } if(ai[4]>=ai[3]*2){ sum++; ind=4; } // System.out.println("JJ"); if(sum!=1){ System.out.println("C"); }else{ System.out.println((char)(bi[ind]+64)); } } } }
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
//package codeforces; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.List; import java.util.StringTokenizer; import java.util.TreeSet; public class A { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); PrintWriter writer = new PrintWriter(System.out); A() throws IOException { // reader = new BufferedReader(new FileReader("input.txt")); // writer = new PrintWriter(new FileWriter("output.txt")); } StringTokenizer stringTokenizer; String next() throws IOException { while (stringTokenizer == null || !stringTokenizer.hasMoreTokens()) { stringTokenizer = new StringTokenizer(reader.readLine()); } return stringTokenizer.nextToken(); } int nextInt() throws IOException { return Integer.parseInt(next()); } long nextLong() throws IOException { return Long.parseLong(next()); } final int MOD = 1000 * 1000 * 1000 + 7; int sum(int a, int b) { a += b; return a >= MOD ? a - MOD : a; } int product(int a, int b) { return (int) (1l * a * b % MOD); } int pow(int x, int k) { int result = 1; while (k > 0) { if (k % 2 == 1) { result = product(result, x); } x = product(x, x); k /= 2; } return result; } int inv(int x) { return pow(x, MOD - 2); } void solve() throws IOException { int[] l = new int[4]; for(int i = 0; i < 4; i++) { l[i] = next().length() - 2; } List<Integer> goodOptions = new ArrayList<>(); for(int i = 0; i < 4; i++) { boolean superShort = true; boolean superLong = true; for(int j = 0; j < 3; j++) { int k = i + j + 1 & 3; if(l[i] * 2 > l[k]) { superShort = false; } if(l[k] * 2 > l[i]) { superLong = false; } } if(superLong || superShort) { goodOptions.add(i); } } if(goodOptions.size() != 1) { writer.println("C"); } else { writer.println((char)('A' + goodOptions.get(0))); } writer.close(); } public static void main(String[] args) throws IOException { new A().solve(); } }
JAVA
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; /** 39/15 = 2 * * */ public class A_Div2_250 { public static void main(String[]arg) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); int i,j,k,l; int[]a = new int[4]; a[0] = in.readLine().length()-2; a[1] = in.readLine().length()-2; a[2] = in.readLine().length()-2; a[3] = in.readLine().length()-2; int ans = 0; char c = '0'; for(i = 0; i < 4; i++) { j = (i + 1)%4; k = (i + 2)%4; l = (i + 3)%4; if(a[i]*2 <= a[j] && a[i]*2 <= a[k] && a[i]*2 <= a[l] || a[i] >= a[j]*2 && a[i] >= a[k]*2 && a[i] >= a[l]*2) { c = (char)('A' + i); ans++; } } if(ans == 1) System.out.println(c); 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; const int INF = 99999999; const int MX = 1000 + 10; using namespace std; char s1[MX], s2[MX], s3[MX], s4[MX]; bool judge(int x1, int x2, int x3, int x4) { if ((x1 * 2 <= x2 && x1 * 2 <= x3 && x1 * 2 <= x4) || (x1 >= x2 * 2 && x1 >= x3 * 2 && x1 >= x4 * 2)) return true; return false; } int main() { while (~scanf("%s%s%s%s", s1, s2, s3, s4)) { int n1 = strlen(s1) - 2; int n2 = strlen(s2) - 2; int n3 = strlen(s3) - 2; int n4 = strlen(s4) - 2; int num = 0; char ch; if (judge(n1, n2, n3, n4)) ch = 'A', num++; if (judge(n2, n1, n3, n4)) ch = 'B', num++; if (judge(n3, n1, n2, n4)) ch = 'C', num++; if (judge(n4, n1, n2, n3)) ch = 'D', num++; if (num == 1) cout << ch << 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; string s1, s2, s3, s4; int i, a, b, c, d, n, x[5]; int main() { cin >> s1; cin >> s2; cin >> s3; cin >> s4; a = s1.size() - 2; b = s2.size() - 2; c = s3.size() - 2; d = s4.size() - 2; if ((a * 2 <= b && a * 2 <= c && a * 2 <= d) || (a >= 2 * b && a >= c * 2 && a >= d * 2)) x[1] = 1; if ((b * 2 <= a && b * 2 <= c && b * 2 <= d) || (b >= 2 * a && b >= c * 2 && b >= d * 2)) x[2] = 1; if ((c * 2 <= b && c * 2 <= a && c * 2 <= d) || (c >= 2 * b && c >= a * 2 && c >= d * 2)) x[3] = 1; if ((d * 2 <= b && d * 2 <= c && d * 2 <= a) || (d >= 2 * b && d >= c * 2 && d >= a * 2)) x[4] = 1; for (i = 1; i <= 4; i++) n += x[i]; if (x[3] || n >= 2) cout << "C"; else if (x[1]) cout << "A"; else if (x[2]) cout << "B"; else if (x[4]) cout << "D"; else cout << "C"; }
CPP
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The child will follow the algorithm: * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great. * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice). You are given a multiple-choice questions, can you predict child's choose? Input The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length. Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_". Output Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes). Examples Input A.VFleaKing_is_the_author_of_this_problem B.Picks_is_the_author_of_this_problem C.Picking_is_the_author_of_this_problem D.Ftiasch_is_cute Output D Input A.ab B.abcde C.ab D.abc Output C Input A.c B.cc C.c D.c Output B Note In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D. In the second sample, no choice is great, so the child will choose the luckiest choice C. In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.
2
7
a = [len(input()) - 2 for i in range(4)] cnt = 0 res = 2 for i in range(4): flag1 = True flag2 = True for j in range(4): if j != i: if a[i] < a[j] * 2: flag1 = False if a[i] * 2 > a[j]: flag2 = False if flag1 or flag2: cnt += 1 res = i if cnt == 1: print(["A", "B", "C", "D"][res]) 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 P7 { 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 great = " "; int cont = 0; if(a1*2 <= b1 && a1*2 <= c1 && a1*2<=d1){great = "A"; cont++;} else if(a1 >=b1*2 && a1 >= c1*2 && a1>= d1*2){great = "A"; cont++;} if(b1*2 <= a1 && b1*2 <= c1 && b1*2<=d1){great = "B"; cont++;} else if(b1 >=a1*2 && b1 >= c1*2 && b1>= d1*2){great = "B"; cont++;} if(c1*2 <= b1 && c1*2 <= a1 && c1*2<=d1){great = "C"; cont++;} else if(c1 >=b1*2 && c1 >= a1*2 && c1>= d1*2){great = "C"; cont++;} if(d1*2 <= b1 && d1*2 <= c1 && d1*2<=a1){great = "D"; cont++;} else if(d1 >=b1*2 && d1 >= c1*2 && d1>= a1*2){great = "D"; cont++;} if(cont == 0 || cont >=2){ System.out.println('C'); } else{ System.out.println(great); } } }
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 TheChildAndHomework { public static void main(String[] args){ Scanner sc = new Scanner(System.in); String[] arc = new String[4]; int j=0; while(j<4 && sc.hasNextLine()){ arc[j]=sc.nextLine(); j++; } sc.close(); String[] des = new String[arc.length]; for(int i=0;i<arc.length;i++){ des[i] = arc[i].split("[.]")[1]; } int[] num = new int[arc.length]; for(int i=0;i<arc.length;i++){ num[i]=des[i].length(); } int min=num[0],max=num[0],min_index=0,max_index=0; for(int i=1;i<num.length;i++){ if(num[i]<min){ min=num[i]; min_index=i; } if(num[i]>max){ max=num[i]; max_index=i; } } for(int i=0;i<num.length;i++){ if(i != min_index && num[i] < 2*min){ min_index=-1; } } for(int i=0;i<num.length;i++){ if(i != max_index && 2*num[i] > max){ max_index=-1; } } if(min_index != -1 && max_index == -1) System.out.print(arc[min_index].split("[.]")[0]); if(max_index != -1 && min_index == -1) System.out.print(arc[max_index].split("[.]")[0]); if((min_index == -1 && max_index == -1) || (min_index !=-1 && max_index != -1)) System.out.print("C"); } }
JAVA