2501. Formula

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.