HDU 5832 A water problem

Problem Description
Two planets named Haha and Xixi in the universe and they were created with the universe beginning.

There is 73 days in Xixi a year and 137 days in Haha a year. 

Now you know the days N after Big Bang, you need to answer whether it is the first day in a year about the two planets.
 

Input
There are several test cases(about 5 huge test cases).

For each test, we have a line with an only integer N(0N), the length of N is up to 10000000.
 

Output
For the i-th test case, output Case #i: , then output "YES" or "NO" for the answer.
 

Sample Input
10001 0 333
 

Sample Output
Case #1: YES Case #2: YES Case #3: NO

一道水题,问一个数能不能被73和137同时整除,数字很长,用字符串读入。

#include<set>
#include<map>
#include<ctime>
#include<cmath>
#include<stack>
#include<queue>
#include<bitset>
#include<cstdio>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<functional>
#define rep(i,j,k) for (int i = j; i <= k; i++)
#define per(i,j,k) for (int i = j; i >= k; i--)
#define lson x << 1, l, mid
#define rson x << 1 | 1, mid + 1, r
#define fi first
#define se second
#define mp(i,j) make_pair(i,j)
#define pii pair<int,int>
using namespace std;
typedef long long LL;
const int low(int x) { return x&-x; }
const double eps = 1e-8;
const int INF = 0x7FFFFFFF;
const int mod = 1e9 + 7;
const int N = 1e7 + 10;
const int read()
{
    char ch = getchar();
    while (ch<'0' || ch>'9') ch = getchar();
    int x = ch - '0';
    while ((ch = getchar()) >= '0'&&ch <= '9') x = x * 10 + ch - '0';
    return x;
}
int T, m, cas = 0;
char n[N];

bool check()
{
    int a = 0, b = 0;
    for (int i = 0; n[i]; i++)
    {
        a = (a * 10 + n[i] - '0') % 73;
        b = (b * 10 + n[i] - '0') % 137;
    }
    return a + b == 0;
}

int main()
{
    while (scanf("%s", n) != EOF)
    {
        printf("Case #%d: %s\n", ++cas,check() ? "YES": "NO");
    }
    return 0;
}


发布了1178 篇原创文章 · 获赞 82 · 访问量 49万+
展开阅读全文

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 大白 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览