HDU 5832 A water problem

    xiaoxiao2025-05-18  5

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

    转载请注明原文地址: https://ju.6miu.com/read-1299024.html
    最新回复(0)