Since learning ACM, yefeng has told people that he can quickly determine whether a positive integer number is a prime number. Later, we guess he only knows how to determine the number within 10 ^ 18. So I want to ask him with a very large number. Of course, for a very large number of yefeng, it cannot be calculated in a short time. Fortunately, yefeng learned the Prime Number Theorem and knew that the larger the number, the lower the probability of the number being a prime number. So he intentionally told everyone a number and attached a sentence, this number is a factor for the number you give, so the number you give is a sum. Smart, can you come up with a way to tell the lie that exposes yefeng?
Several groups of test data, each group of test data in two rows, the first row is the number of yefeng to determine a (10 ^ 20 <= A <= 10 ^ 1000 ), the second row is yefeng's guess factor B (2 <= B <= 9999 ). The data guarantee integer does not have a leading 0.
If B is a factor of A, yes is output; otherwise, the remainder is output.
546112345612312369851232 2 145645612123123154654319 2 output yes1
# Include <stdio. h> # include <string. h> // (A * B) % C = (a % C) * (B % C) % C; int row (int K, int N) // (a + B) % C = (a % C + B % C) % C for multiple multiplication, the addition is similar. {Int F = 1, R = 1, I; for (I = 0; I <k/6; I ++) // downgrade, drop six bits each time (because the six-digit number can be reduced) f * = 1000000% N; for (I = 0; I <K % 6; I ++) R * = 10; return f * (R % N) % N;} int main () {char a [1001]; int N, K, K1, C, B; while (scanf ("% s", )! = EOF) {int sum = 0; scanf ("% d", & N); k1 = k = strlen (a)-1; for (INT I = 0; I <= K; I ++) {c = (a [I]-48) % N; B = row (K1 --, N ); sum + = (C * B) % N;} If (sum % N = 0) printf ("Yes \ n"); else printf ("% d \ n ", sum % N) ;}return 0 ;}