HDU 5832 A water problem(水~)

来源:互联网 发布:老a淘宝工具箱 编辑:程序博客网 时间:2024/06/05 19:08

Description
输入一个整数,判断其是否同时是73和137的倍数
Input
多组用例,每组用例输入一个长度不超过10^7的数字串表示一个整数,以文件尾结束输入
Output
对于每组用例,如果该数是73和137的倍数则输出YES,否则输出NO
Sample Input
10001
0
333
Sample Output
Case #1: YES
Case #2: YES
Case #3: NO
Solution
大数取模,水题
Code

#include<cstdio>#include<iostream>#include<cstring>#include<algorithm>using namespace std;#define maxn 10000001char s[maxn];int main(){    int Case=1;    while(~scanf("%s",s))    {        int n=strlen(s),a=0,b=0;        for(int i=0;i<n;i++)            a=(10*a+s[i]-'0')%73,b=(10*b+s[i]-'0')%137;        printf("Case #%d: %s\n",Case++,a+b==0?"YES":"NO");    }    return 0;}
0 0
原创粉丝点击