hdu 5832 A water problem 大数+带坑水题

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5832

【题意】求n是否满足 n%73==0&&n%137==0,n的长度为10^7.

【解题思路】坑1:n的“长度”为10^7而不是大小!(看到是水题orz我居然直接提交了n%73==0&&n%137==0

      坑2:输入的时间问题!用cin读入超时! 发现73和137均为质数且73*137=10001,n作为字符串读入再依次对10001取模,判断最终余数是否为0即可。

代码如下:

#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
#define ll long long
const int maxn=10000009;
char s[maxn];
int n;
int main()
{
    int c=1;
    while(gets(s))
    {
        int x=0;
        n=strlen(s);
        for(int i=0;i<n;i++)
            x=(x*10+s[i]-'0')%10001;
        if(x) printf("Case #%d: NO\n",c);
        else printf("Case #%d: YES\n",c);
        c++;
    }
    return 0;
}

 

posted @ 2016-08-15 15:03  Colarise  阅读(173)  评论(0)    收藏  举报