好题啊,被HACK了。曾经做题都是人数越来越多。这次比赛 PASS人数 从2000直掉 1000人  被HACK  1000多人!

没见过的科技啊



1 2 4 8 这组数 被黑的

A. The Child and Homework
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

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

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

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

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

Input

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

Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase 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 test(s)
input
A.VFleaKing_is_the_author_of_this_problem
B.Picks_is_the_author_of_this_problem
C.Picking_is_the_author_of_this_problem
D.Ftiasch_is_cute
output
D
input
A.ab
B.abcde
C.ab
D.abc
output
C
input
A.c
B.cc
C.c
D.c
output
B
Note

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

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

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

AC:

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
const int N = 110;
using namespace std;
char a[10][N];
int s[10];
int main()
{
for(int i = 0;i<4;i++)
{
scanf("%s",a[i]);
s[i] = strlen(a[i]);
s[i] -=2;
}
int flag = 0,flag1 = 0;
sort(s,s+4);
int ma = s[3];
int mi = s[0];
for(int i = 1;i<4;i++)
{
if(s[0]==0)
break;
if((s[i]/s[0])>=2)
{
flag++;
}
}
for(int i = 0;i<3;i++)
{
if(s[i]==0)
break;
if((s[3]/s[i])>=2)
{
flag1++; }
} if(flag1==3 && flag!=3)
{
for(int i = 0;i<4;i++)
{
int len = strlen(a[i]);
len -= 2;
if(len==ma)
{
printf("%c",'A'+i);
}
}
}
else if(flag==3 && flag1!=3)
{
for(int i = 0;i<4;i++)
{
int len = strlen(a[i]);
len -=2;
if(len==mi)
{
printf("%c",'A'+i);
}
}
}
else
printf("C\n"); return 0;
}

Codeforces Round #250 (Div. 2)—A. The Child and Homework的更多相关文章

  1. Codeforces Round #250 (Div. 2) A. The Child and Homework

    注意题目长度不能考虑前缀,而且如果即存在一个选项的长度的两倍小于其他所有选项的长度,也存在一个选项的长度大于其他选项长度的两倍,则答案不是一个好的选择,只能选择C. #include <iost ...

  2. Codeforces Round #250 (Div. 1) D. The Child and Sequence 线段树 区间取摸

    D. The Child and Sequence Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest ...

  3. Codeforces Round #250 (Div. 1) B. The Child and Zoo 并查集

    B. The Child and Zoo Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/438/ ...

  4. Codeforces Round #250 (Div. 1) A. The Child and Toy 水题

    A. The Child and Toy Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/438/ ...

  5. Codeforces Round #250 (Div. 1) D. The Child and Sequence (线段树)

    题目链接:http://codeforces.com/problemset/problem/438/D 给你n个数,m个操作,1操作是查询l到r之间的和,2操作是将l到r之间大于等于x的数xor于x, ...

  6. Codeforces Round #250 (Div. 1) D. The Child and Sequence(线段树)

    D. The Child and Sequence time limit per test 4 seconds memory limit per test 256 megabytes input st ...

  7. Codeforces Round #250 (Div. 1) D. The Child and Sequence

    D. The Child and Sequence time limit per test 4 seconds memory limit per test 256 megabytes input st ...

  8. Codeforces Round #250 (Div. 2) D. The Child and Zoo 并查集

    D. The Child and Zoo time limit per test 2 seconds memory limit per test 256 megabytes input standar ...

  9. Codeforces Round #250 (Div. 2)B. The Child and Set 暴力

    B. The Child and Set   At the children's day, the child came to Picks's house, and messed his house ...

随机推荐

  1. 全面理解js面向对象

    前言 当今 JavaScript 大行其道,各种应用对其依赖日深.web 程序员已逐渐习惯使用各种优秀的 JavaScript 框架快速开发 Web 应用,从而忽略了对原生 JavaScript 的学 ...

  2. BZOJ 1996: [Hnoi2010]chorus 合唱队(dp)

    简单的dp题..不能更水了.. --------------------------------------------------------------- #include<cstdio&g ...

  3. pthread_wrap.h

    #ifndef _PTHREAD_WRAP_H#define _PTHREAD_WRAP_H#include <pthread.h> class hm_pthread_mutex{publ ...

  4. Eclipse4.3正式版已发布

    Eclipse4.3正式版已发布,传送门http://www.eclipse.org/downloads/

  5. Githut Token (hidden): Githut 安装验证

    登录https://github.com 进入https://github.com/settings/profile 参考 http://jingyan.baidu.com/article/22fe7 ...

  6. bzoj 1047 : [HAOI2007]理想的正方形 单调队列dp

    题目链接 1047: [HAOI2007]理想的正方形 Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 2369  Solved: 1266[Submi ...

  7. ASP.NET MVC5 学习笔记-4 OWIN和Katana

    1. Owin OWIN全名:Open Web Interface for .NET. 它是一个说明,而非一个框架,该声明用来实现Web服务器和框架的松耦合.它提供了模块化.轻量级和便携的设计.类似N ...

  8. SubLime2 win + mac keygen

    参考 http://www.cnblogs.com/snandy/archive/2013/05/08/3068059.html http://www.freebuf.com/tools/6434.h ...

  9. css3: css3选择器

    --------------------css3选择器-------------------------css3属性选择器  ~~属性选择器基本上ie7+都支持,可以相对放心的使用 见: www.ca ...

  10. mysql读写分离

    严格意义上讲,MySQL 读.写分离确实存在上述情况,这是由Master-Slave 异步复制存在延迟所导致的,且Master binlog的写入为多线程,而Slave同步的sql_thread为单线 ...