2016Y GDUT新生杯初赛 Problem B: 签到题
来源:互联网 发布:淘宝我的投诉在哪里看 编辑:程序博客网 时间:2024/05/06 21:37
Problem B: 签到题
Description
某一天,北原春希、小木曾雪菜和冬马和纱分享幸福度。他们希望三人能平等获得这份幸福,否则他们就会各奔东西。于是叫你来判断他们能否三个人快乐的玩耍下去。
Input
输入数据为T组(T <= 100),每组数据读入一个幸福度n。(1<=n的位数<=500)
Output
对于每个测试实例,如果三人能平等获得幸福,则输出“Three people are the most stable”,否则输出“Why would it be like this”。双引号不用输出。
Sample Input
3
111111111
333333333333333333333333333333333333333333333
11111111111111111111111111111111111111111111
Sample Output
Three people are the most stable
Three people are the most stable
Why would it be like this
分析解答:
这是一个签到题,然后坑了我一大波。
首先看一下数据规模,人家都讲多少位而不讲数据规模了,足以见得,这不是一道能用int甚至unsigned long long 能解决,所以,这就是字符串的事情了。
然后,我们知道,怎么能被3整除?各位加起来对3取模==0就能被3整除啦。
呐呐呐,这里就有一个坑了,他喵的他没有说是整数昂,那么我们就要考虑小数的啦,我们加的时候不能把小数点加进来呀,还有负数的符号昂,那么,怎么解决?判断这个字符是不是大于等于0小于等于9就好啦呗,咳咳,这确实是一道签到题的,还是我太菜
上代码:
#include<iostream>#include<string>using namespace std;typedef unsigned long long ULL;int main(){ ios::sync_with_stdio(false); int T; cin>>T; while(T--) { string in; ULL ans=0; cin>>in; for(auto &i:in) { if((i-'0')>-1 && (i-'0')<10) ans+=(i-'0'); } if(ans%3) cout<<"Why would it be like this\n"; else cout<<"Three people are the most stable\n"; }}
- 2016Y GDUT新生杯初赛 Problem B: 签到题
- 2016Y GDUT新生杯初赛 Problem C: 算罚时
- 2016Y GDUT新生杯初赛 Problem E: 套套套
- 2016Y GDUT新生杯初赛 Problem F: 吃豆豆
- 2016Y GDUT新生杯初赛 Problem I: 神枪手TMK
- 2016Y GDUT新生杯初赛 Problem J: 神龙的烦恼(初赛更新完结)
- 2016Y GDUT新生杯初赛 Problem A: 贪吃的zhazhahe
- 2016Y GDUT新生杯初赛 Problem D: 有趣的游戏
- 2016Y GDUT新生杯初赛 Problem G: Pigofzhou和他的那么多个学妹
- 2016Y GDUT新生杯初赛 Problem H: 神奇的清华大大的神奇魔法
- 2016 Y GDUT新生杯决赛 Problem F: 神偷TMK
- 2016 Y GDUT新生杯决赛 Problem G: 神偷TMK后续
- GDUT新生赛—B
- GDUT 2016新生赛D题 有趣的游戏
- 2016广东工业大学新生杯决赛:Problem B: Zhazhahe究竟有多二
- 华东交通大学2016届新生选拔赛:1010 我是签到题
- 2016 GDUT Individual Contest2_A题_codeforces 416B(暴力)
- GDUT初赛题解
- Spring框架学习笔记
- MySql group by concat
- LeetCode 171 Excel Sheet Column Number题解
- python:read,readlines,readline的区别
- C数据类型相关问题
- 2016Y GDUT新生杯初赛 Problem B: 签到题
- ios 类似Uber的启动视频开发
- 一个http请求二次请求才能获取到数据,为什么,url的问题?
- perl 监控数据库用到的数据结构
- 使用Kendo 输入验证的几种方法
- C&C++获取时间的相关问题
- 浅谈asch系统的共识机制与容错性
- Android-关于资源文件shape的详解
- 进入新界面editText获取焦点 并且隐藏软键盘