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";    }}


0 0
原创粉丝点击