xtu read problem training 3 A - The Child and Homework

The Child and Homework

Time Limit: 1000ms

Memory Limit: 262144KB

This problem will be judged on CodeForces. Original ID: 437A
64-bit integer IO format: %I64d      Java class name: (Any)

Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct.

Fortunately the child knows how to solve such complicated test. The child will follow the algorithm:

  • If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great.
  • If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice).

You are given a multiple-choice questions, can you predict child‘s choose?

Input

The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn‘t be counted in description‘s length.

Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_".

Output

Print a single line with the child‘s choice: "A", "B", "C" or "D" (without quotes).

Sample Input

Input

A.VFleaKing_is_the_author_of_this_problemB.Picks_is_the_author_of_this_problemC.Picking_is_the_author_of_this_problemD.Ftiasch_is_cute

Output

D

Input

A.abB.abcdeC.abD.abc

Output

C

Input

A.cB.ccC.cD.c

Output

B

Hint

In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices‘, so it is great choice. There is no other great choices so the child will choose D.

In the second sample, no choice is great, so the child will choose the luckiest choice C.

In the third sample, the choice B (length 2) is twice longer than all other choices‘, so it is great choice. There is no other great choices so the child will choose B.

Source

Codeforces Round #250 (Div. 2)

 1 #include <iostream>
 2 #include <cstdio>
 3 #include <cstring>
 4 #include <cmath>
 5 #include <algorithm>
 6 #include <climits>
 7 #include <vector>
 8 #include <queue>
 9 #include <cstdlib>
10 #include <string>
11 #include <set>
12 #define LL long long
13 #define INF 0x3f3f3f3f
14 using namespace std;
15 struct node {
16     char str[1000];
17     int len,index;
18 };
19 bool cmp(const node &x,const node &y) {
20     return x.len < y.len;
21 }
22 node p[4];
23 int main() {
24     int i,j;
25     for(i = 0; i < 4; i++) {
26         scanf("%s",p[i].str);
27         p[i].len = strlen(p[i].str)-2;
28         p[i].index = i;
29     }
30     sort(p,p+4,cmp);
31     for(i = 1; i < 4; i++) {
32         if(p[i].len < p[0].len*2) break;
33     }
34     for(j = 0; j < 3; j++)
35         if(p[j].len*2 > p[3].len) break;
36     if(i == 4 && j == 3 || i < 4 && j < 3) puts("C");
37     else printf("%c\n",i == 4?p[0].index+‘A‘:p[3].index+‘A‘);
38     return 0;
39 }

xtu read problem training 3 A - The Child and Homework

时间: 2024-10-06 06:46:06

xtu read problem training 3 A - The Child and Homework的相关文章

xtu read problem training 4 B - Multiplication Puzzle

Multiplication Puzzle Time Limit: 1000ms Memory Limit: 65536KB This problem will be judged on PKU. Original ID: 165164-bit integer IO format: %lld      Java class name: Main The multiplication puzzle is played with a row of cards, each containing a s

xtu read problem training 4 A - Moving Tables

Moving Tables Time Limit: 2000ms Memory Limit: 65536KB This problem will be judged on ZJU. Original ID: 102964-bit integer IO format: %lld      Java class name: Main The famous ACM (Advanced Computer Maker) Company has rented a floor of a building wh

xtu read problem training 2 B - In 7-bit

In 7-bit Time Limit: 2000ms Memory Limit: 65536KB This problem will be judged on ZJU. Original ID: 371364-bit integer IO format: %lld      Java class name: Main Very often, especially in programming contests, we treat a sequence of non-whitespace cha

xtu read problem training A - Dividing

A - Dividing Time Limit:1000MS     Memory Limit:10000KB     64bit IO Format:%I64d & %I64u Description Marsha and Bill own a collection of marbles. They want to split the collection among themselves so that both receive an equal share of the marbles.

xtu read problem training 3 B - Gears

Gears Time Limit: 2000ms Memory Limit: 65536KB This problem will be judged on ZJU. Original ID: 378964-bit integer IO format: %lld      Java class name: Main Bob has N (1 ≤ N ≤ 2*105) gears (numbered from 1 to N). Each gear can rotate clockwise or co

xtu read problem training B - Tour

B - Tour Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Description John Doe, a skilled pilot, enjoys traveling. While on vacation, he rents a small plane and starts visiting beautiful places. To save money, John must de

codeforces --- Round #250 (Div. 2) A. The Child and Homework

<传送门> 这题就是一个坑,尼玛wa了一大片啊. 自己被hack了,比赛结束后改了又wa两次才过. [题目大意] 其实就是一个猜题小技巧(联系自己初中考试的时候怎么猜题的,这题就好理解多了).这位同学是这样来选答案的:1.如果有一些选项长度至少比其他所有的描述短两倍,或至少超过所有其他的描述的两倍,那么孩子认为这个选择很可能是正确的.2.如果正好满足以上其中一种条件(重点),这个同学就会选择它,否则就选C.给你一个选择题,让你选择出这个同学将会选择的答案. [题目分析] 首先,这个题目就是一个

A. The Child and Homework

http://codeforces.com/contest/437/problem/A 1 import java.util.ArrayList; 2 import java.util.Scanner; 3 4 public class Main { 5 6 public static void main(String[] args) { 7 Scanner in = new Scanner(System.in); 8 while (in.hasNext()){ 9 int[]len=new i

[C5] Andrew Ng - Structuring Machine Learning Projects

About this Course You will learn how to build a successful machine learning project. If you aspire to be a technical leader in AI, and know how to set direction for your team's work, this course will show you how. Much of this content has never been