Codeforces 437A The Child and Homework(水题)
来源:互联网 发布:cf手游刷枪软件不封号 编辑:程序博客网 时间:2024/06/01 07:15
题目链接:Codeforces 437A The Child and Homework
题目大意:有个小孩在考试,碰到一道题目不会做,所以用猜的,三长一短选最短,三短一长选最长,否则选C。就是看选项中是否有一个选项的长度是否小于其他三个选项长度的一半或者大于其他长度的两倍。如果有多个或是没有,就选择C。
解题思路:题目懂了就是水题了,不解释。
#include <cstdio>#include <cstring>int l[4];char str[105];bool judgeLonger (int x) { for (int i = 0; i < 4; i++) { if (i == x) continue; if (l[i] * 2 > l[x]) return false; } return true;}bool judgeShorter(int x) { for (int i = 0; i < 4; i++) { if (i == x) continue; if (l[i] < l[x] * 2) return false; } return true;}int main () { for (int i = 0; i < 4; i++) { scanf("%s", str); l[str[0]-'A'] = strlen(str+2); } int cnt = 0, ans = 0; for (int i = 0; i < 4; i++) { if (judgeLonger(i) || judgeShorter(i)) { cnt++; ans = i; } } if (cnt == 1) printf("%c\n", ans + 'A'); else printf("C\n"); return 0;}
0 0
- Codeforces 437A The Child and Homework
- CodeForces 437 A. The Child and Homework
- Codeforces 437A The Child and Homework
- Codeforces 437A The Child and Homework
- Codeforces 437A The Child and Homework(水题)
- A. The Child and Homework
- Codeforces Round #250 (Div. 2) A. The Child and Homework
- Codeforces Round #250 (Div. 2) A - The Child and Homework
- Codeforces #250 (Div. 2) A. The Child and Homework
- Codeforces Round #250 (Div. 2) 437A The Child and Homework(模拟)
- Codeforces Round #250 (Div. 2)—A. The Child and Homework
- cf437A The Child and Homework
- #250 div.2 A. The Child and Homework
- CF #250 The Child and Homework
- G - The Child and Set-CodeForces 437B-水题
- H - The Child and Toy-CodeForces 437C-水题
- Codeforces 437B The Child and Set
- codeforces 437C The Child and Toy
- 列出指定目录下后缀是.mp3的所有文件
- TSQL与PLSQL差异整理
- 去除List列表中重复值(稍作调整,也适合于List<T> 和 List<?>)
- RGB888转RGB565
- 列出指定目录下与正则表达式”*.sh”匹配的所有文件
- Codeforces 437A The Child and Homework(水题)
- LDA学习
- 学习HTML必须了解的一些基础知识
- 列出指定目录下与正则表达式”abc*”匹配的所有文件
- cocos2d-x 旅程开始--(实现单击与长按)
- C++ 文件夹的一些操作
- Python串口通信--pyseral
- 如何让HTML5调用手机摄像头拍照——实践就是一切
- Linux内核编程(一) —— 内核模块加载