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

<传送门>

这题就是一个坑,尼玛wa了一大片啊。

自己被hack了,比赛结束后改了又wa两次才过。

【题目大意】

其实就是一个猜题小技巧(联系自己初中考试的时候怎么猜题的,这题就好理解多了)。
这位同学是这样来选答案的:
1.如果有一些选项长度至少比其他所有的描述短两倍,或至少超过所有其他的描述的两倍,那么孩子认为这个选择很可能是正确的。
2.如果正好满足以上其中一种条件(重点),这个同学就会选择它,否则就选C.
给你一个选择题,让你选择出这个同学将会选择的答案。

【题目分析】

首先,这个题目就是一个模拟,模拟本身不难,想一下就有思路了,但是只怪很多人都没看清题目,只怪审题不仔细啊。

题目里面有句话是很关键的:If there is exactly one great choice then the child chooses
it.

也就是说,如果两个条件都满足的话,这位同学就不知道哪个的正确概率大,所以他又转过来选C。

#include<bits/stdc++.h>
using namespace std;
int main()
{
// freopen("cin.txt","r",stdin);
int i,j;
int len[5];
char str[4][200];
for(i=0;i<4;i++)
{
scanf("%s",str[i]);
len[i]=strlen(str[i])-2;
}
int Find1=0,mark1;
for(i=0;i<4;i++)
{
if(len[i]*6<=(len[(i+1)%4]+len[(i+2)%4]+len[(i+3)%4])) //找到了有可能符合条件的选项
{
Find1=1;
mark1=i;
// cout<<"if-1"<<endl;
for(j=0;j<4;j++) //继续判断
{
if(j!=i)
{
if(len[i]*2>len[j])
{
Find1=2; //不符合
break;
}
}
}
if(Find1==1) //判断一遍后任然成立,那就说明这个选项符合
break;
}
}
int Find2=0,mark2;
for(i=0;i<4;i++)
{
if(len[i]*6>=(len[(i+1)%4]+len[(i+2)%4]+len[(i+3)%4])) //找到了有可能符合条件的选项
{
Find2=1;
mark2=i;
// cout<<"if-2"<<endl;
for(j=0;j<4;j++) //继续判断
{
if(j!=i)
{
if(len[i]<len[j]*2)
{
Find2=2; //不符合
break;
}
}
}
if(Find2==1) //判断一遍后任然成立,那就说明这个选项符合
break;
}
}
// cout<<"mark="<<mark<<endl;
if(Find1==1&&Find2==1)
{
printf("C\n");
return 0;
}
if(Find1==1)
printf("%c\n",mark1+‘A‘);
else if(Find2==1)
printf("%c\n",mark2+‘A‘);
else
printf("C\n");
return 0;
}

codeforces --- Round #250 (Div. 2) A. The Child and
Homework,布布扣,bubuko.com

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

时间: 2024-08-05 11:12:56

codeforces --- Round #250 (Div. 2) A. The Child and Homework的相关文章

codeforces --- Round #250 (Div. 2) B. The Child and Set

<传送门> [题目大意] 给你一个sum和一个limit,现在要你在1~limit中找到一些数来使得这些数的和等于sum,如果能找到的话就输出找到的数的个数和这些数,未找到输出"-1". 比赛的时候被hack了. [题目分析] 这题需要将所有的数的lowbit先求出来,然后按照大小排序,然后从后往前判断,如果这个数小于sum那么这个数就是可以构成sum的数,选进去,完了以后判断sum的值是否为0就可以了.做题的时候没将题目理解透彻. #include<bits/std

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 up. Picks was angry at him. A lot of important things were lost, in particular the favorite set of Picks. Fortunately, Picks remembers something about h

Codeforces Round #250 (Div. 1) D. The Child and Sequence 线段树 区间求和+点修改+区间取模

D. The Child and Sequence At the children's day, the child came to Picks's house, and messed his house up. Picks was angry at him. A lot of important things were lost, in particular the favorite sequence of Picks. Fortunately, Picks remembers how to

Codeforces Round #250 (Div. 1) B. The Child and Zoo(排序+并查集)(常规好题)

B. The Child and Zoo time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Of course our child likes walking in a zoo. The zoo has n areas, that are numbered from 1 to n. The i-th area contains 

Codeforces Round #250 (Div. 2) C. The Child and Toy 详解

output standard output On Children's Day, the child got a toy from Delayyy as a present. However, the child is so naughty that he can't wait to destroy the toy. The toy consists of n parts and m ropes. Each rope links two parts, but every pair of par

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,3操作是将下标为k的数变为x. 注意成段更新的时候,遇到一个区间的最大值还小于x的话就停止更新. 1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 using namespace std; 5

Codeforces Round #250 (Div. 2) C、The Child and Toy

注意此题,每一个部分都有一个能量值v[i],他移除第i部分所需的能量是v[f[1]]+v[f[2]]+...+v[f[k]],其中f[1],f[2],...,f[k]是与i直接相连(且还未被移除)的部分的编号. 注意题目移除的都是与第i部分直接相连的部分的能量值, 将本题目简化得,只考虑两个点1和2,1和2相连,1的能量值是10,2的能量值是20, 移除绳子时,要保持能量最小,可以移除部分2,这样移除的能量就是与2相连的部分1的能量即是10: 故每次相连两部分都移除能量值大的即可 #includ

Codeforces Round #250 (Div. 2)——The Child and Set

题目链接 题意: 给定goal和limit,求1-limit中的若干个数,每一个数最多出现一次,且这些数的lowbit()值之和等于goal,假设存在这种一些数,输出个数和每一个数:否则-1 分析: 先考虑一下比較普通的情况,给一些数,和一个goal,问时候能达到.(最好还是设这些数已经从大到小排序) 考虑能否够贪心,对于当前的数x: 1.之后的数的和能等于x,那么假设x<=goal,显然必须选x: 2.之后的数的和能等于x-1,那么同上(这个情况就是二进制的情况) 3.之后的数的和不包含上述两

Codeforces Round #250 (Div. 1)

这几次CF都挺惨.. A 没条边权设为两端点的最小点权,最后加起来. 数组开小,WA一次 1 #include <iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 #include<stdlib.h> 6 #include<vector> 7 #include<cmath> 8 #include<queue> 9 #