Codeforces Round #250 (Div. 2)—A. The Child and Homework
好题啊,被HACK了。曾经做题都是人数越来越多。这次比赛 PASS人数 从2000直掉 1000人 被HACK 1000多人!
!
!
!
没见过的科技啊
1 2 4 8 这组数 被黑的
1 second
256 megabytes
standard input
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?
The first line starts with "A." (without quotes), then followed the description of choice A.
The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please
note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length.
Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_".
Print a single line with the child's choice: "A", "B", "C"
or "D" (without quotes).
A.VFleaKing_is_the_author_of_this_problem
B.Picks_is_the_author_of_this_problem
C.Picking_is_the_author_of_this_problem
D.Ftiasch_is_cute
D
A.ab
B.abcde
C.ab
D.abc
C
A.c
B.cc
C.c
D.c
B
In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length
15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D.
In the second sample, no choice is great, so the child will choose the luckiest choice C.
In the third sample, the choice B (length 2) 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的更多相关文章
- Codeforces Round #250 (Div. 2) A. The Child and Homework
注意题目长度不能考虑前缀,而且如果即存在一个选项的长度的两倍小于其他所有选项的长度,也存在一个选项的长度大于其他选项长度的两倍,则答案不是一个好的选择,只能选择C. #include <iost ...
- 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 ...
- 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/ ...
- 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/ ...
- 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, ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
随机推荐
- connot find one or more components. please reinstall the application
正在用 Visual Studio 2013 写程序,程序一直执行正常. 此时,手动把注册表"HKEY_USERS"的当前用户的权限删除.再运行程序会提示:“是否继续并运行上次的成 ...
- zoj 2229 Ride to School
所有车子到达的总时间算出来,然后从小到大排序,如果:1. 开始时间 < 0 的,不予考虑,太快的赶不上,太慢的赶上也没用.2. 开始时间 > 0 的,Charley 和最早到达的车子一起到 ...
- JBoss 系列七十:一个简单的 CDI Web 应用
概述 本文通过一个简单的 CDI Web 应用演示dependency injection, scope, qualifiers 以及EL整合.应用部署完成后我们可以通过http://localhos ...
- php如何开启GD库
GD库是干什么用的呢!它是php处理图形的扩展库,GD库提供了一系列用来处理图片的API,使用GD库可以处理图片,或者生成图片.GD库在php中默认是没有开启的,如果想让它支持图片处理功能,那么就要手 ...
- 批量 GBK 转 UTF8 java
package encoding; import java.io.File; import java.io.IOException; import java.util.Collection; impo ...
- 给内置对象或自定义对象添加存取器属性(getter setter)的方法总结
funct = { get: function() { return this._x }, set: function(value) { this._x = value } } function Ob ...
- 完成端口(Completion Port)详解(超级长,超级清楚)
http://www.cnblogs.com/lancidie/archive/2011/12/19/2293773.html
- cout输出各种进制
cout使用: int main(){ int a=10; cout<<"Dec:"<<a<<endl; cout<<hex&l ...
- Android JNI入门第五篇——基本数据类型使用
前面讲到了java和native数据类型,这里就开始做一下使用: 第一步:新建工程 第二部:书写 java方法: public class NativeMethod { static { System ...
- ASP.NET页面传值的几种方式
页面传值是学习asp.net初期都会面临的一个问题,总的来说有页面传值. 存储对象传值.ajax.类.model.表单等!下面欧柏泰克和大家一起来看看asp.net页面传值方式一般有哪些?常用的较简单 ...