2501. Formula
Description
_ Gxx encountered a troublesome formula: S = N1 + N2 + N3 +... + NK, known N, K, and evaluate the value of S. Because _ gxx is poor in mathematics, I hope you can tell him the answer. But because his mathematics is really bad, you just need to tell him to divide s by the remainder of 9901.
Input
Two integers: N and K (n ≤ 1000, K ≤ 109 ).
Output
A number, which indicates dividing s by the remainder of 9901.
Sample Input
2 3
Sample output
14
Problem Source
Golden Week competition-the last sprint of the provincial Competition
Ferma's theorem. If a is an integer and P is a prime number,
That is, the cycle is equal to 1,9901 is a prime number. Therefore, you only need to calculate the sum of K modulo 9900.
# Include <iostream> using namespace STD; int main () {int N, K; CIN> N> K; int M = K % 9900, sum = 0; for (INT I = 0; I <m; I ++) {sum = (sum + 1) * n; sum % = 9901 ;}cout <sum <Endl; return 0 ;}