Problems of large numbers modulo pseudo-precision

Training 1 - E title

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

There is 7373 days in Xixi a year and 137137 days in Haha a year.

Now you know the days NN 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 55 huge test cases).

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

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

#pragma warning (disable:4996)
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <bitset>
#include <stack>
#include <queue>
#define inf 0X7f7f7f7f
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int maxn = 1e7 + 5;
const int M = 9;//状压

char str[maxn];

int main()
{
	int cas = 0;
	while (scanf("%s", str) != EOF)
	{
	int tmp = 0;//不会超1e6
	for (int i = 0; i < strlen(str); i++)
		tmp = (tmp * 10 + str[i] - '0') % 10001;
	if (tmp == 0)
		printf("Case #%d: YES\n", ++cas);
	else
		printf("Case #%d: NO\n", ++cas);
	}
	return 0;
}

Idea:
set the number of input x, if satisfied x% 73 == 0 && x% 137 == 0, because the least common multiple of 73 and 73 is 137 * 137 = 10001, the condition is the x% 10001 == 0, answer Yes output; output contrary no.
Large numbers modulo operation can be used str [i] - '0' indicates the i-th bit number a [i], x = Σ a [i] * 10 ^ (i-1), and because (a + b )% m == a% m + b% m, can be a [i] modulo result of accumulating the results obtained modulo x.

Published 28 original articles · won praise 0 · Views 342

Guess you like

Origin blog.csdn.net/xukeke12138/article/details/104530600