xtu read problem training 3 A - The Child and Homework
The Child and Homework
This problem will be judged on CodeForces. Original ID: 437A
64-bit integer IO format: %I64d Java class name: (Any)
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
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
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
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <queue>
#include <cstdlib>
#include <string>
#include <set>
#define LL long long
#define INF 0x3f3f3f3f
using namespace std;
struct node {
char str[];
int len,index;
};
bool cmp(const node &x,const node &y) {
return x.len < y.len;
}
node p[];
int main() {
int i,j;
for(i = ; i < ; i++) {
scanf("%s",p[i].str);
p[i].len = strlen(p[i].str)-;
p[i].index = i;
}
sort(p,p+,cmp);
for(i = ; i < ; i++) {
if(p[i].len < p[].len*) break;
}
for(j = ; j < ; j++)
if(p[j].len* > p[].len) break;
if(i == && j == || i < && j < ) puts("C");
else printf("%c\n",i == ?p[].index+'A':p[].index+'A');
return ;
}
xtu read problem training 3 A - The Child and Homework的更多相关文章
- xtu read problem training 3 B - Gears
Gears Time Limit: 2000ms Memory Limit: 65536KB This problem will be judged on ZJU. Original ID: 3789 ...
- 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: 3 ...
- xtu read problem training 4 A - Moving Tables
Moving Tables Time Limit: 2000ms Memory Limit: 65536KB This problem will be judged on ZJU. Original ...
- xtu read problem training 4 B - Multiplication Puzzle
Multiplication Puzzle Time Limit: 1000ms Memory Limit: 65536KB This problem will be judged on PKU. O ...
- xtu read problem training B - Tour
B - Tour Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Descriptio ...
- xtu read problem training A - Dividing
A - Dividing Time Limit:1000MS Memory Limit:10000KB 64bit IO Format:%I64d & %I64u Descri ...
- cf437A The Child and Homework
A. The Child and Homework time limit per test 1 second memory limit per test 256 megabytes input sta ...
- Codeforces Round #250 (Div. 2)—A. The Child and Homework
好题啊,被HACK了.曾经做题都是人数越来越多.这次比赛 PASS人数 从2000直掉 1000人 被HACK 1000多人! ! ! ! 没见过的科技啊 1 2 4 8 这组数 被黑的 ...
- Codeforces 437A The Child and Homework
题目链接:Codeforces 437A The Child and Homework 少看了一个条件,最后被HACK掉到203名,要不然就冲到100多一点了==.. 做这个题收获最大的是英语,A t ...
随机推荐
- linux的目录结构详细介绍
linux的目录结构详细介绍 1. /目录(根目录) 2./ect/目录 特定主机系统范围内的配置文件. 3./usr/目录 默认软件都会存于该目录下.用于存储只读用户数据的第二层次:包含绝大多数的用 ...
- 486 Predict the Winner 预测赢家
给定一个表示分数的非负整数数组. 玩家1从数组任意一端拿取一个分数,随后玩家2继续从剩余数组任意一端拿取分数,然后玩家1拿,…….每次一个玩家只能拿取一个分数,分数被拿取之后不再可取.直到没有剩余分数 ...
- 总结这几天学到的HTML标签
1.基础知识W3S,操作慕课网或者FCC网 2.标签必须闭合 标签一般成对出现如:<h1>xxxx</h1> 标签也有空内容标签如:<br/> 标签的属性和属性值放 ...
- BottomNavigationBar底部导航条用法
先来张效果图 接下来是实现过程 1.加入依赖 compile 'com.ashokvarma.android:bottom-navigation-bar:1.3.0' 2.xml布局 fragment ...
- anzhuaggeoip
1.因启动geoip模块,需要先安装GeoIP # wget http://geolite.maxmind.com/download/geoip/api/c/GeoIP.tar.gz # tar xv ...
- 移除sql数据所有链接用户
use master; go declare @temp nvarchar(20) declare myCurse cursor for select spid from sy ...
- Django创建第一个应用
一.创建第一个应用,并在settings.py中添加. python manage.py startapp article 二.创建第一个模型 class Article(models.Model): ...
- systemtap执行过程中报probe timer.profile registration error
probe timer.profile registration error 今天在执行火焰图的过程中,代码报错,probe timer.profile registration error 经过查询 ...
- uva1612 Guess
和cf的打分有点像啊 因为一共只有三道题,所以每个人的得分最多有8种可能性.把这8种可能性都算出来,存在数组里,排好序备用排名就是一个天然的链表,给出了扫描的顺序扫描时,维护两个变量:前一个playe ...
- MFC_综述
第一天(win消息机制.SDK编程基础) 1.基本概念介绍(SDK.API.句柄.消息队列.winmain函数) 2.第一个Windows界面程序(winAPI) 3.消息循环和窗口 ...