#P6271. [湖北省队互测2014] 一个人的数论
[湖北省队互测2014] 一个人的数论
Description
One day, hjy96 came up with a number theory problem:
For a non-negative integer and a positive integer , define as the sum of the -th powers of all positive integers less than and coprime to . For example, .
Given and , find the value of . Output the result modulo .
Of course, hjy96 knows how to do it. But he wants to challenge you...
Input Format
Since may be very large, we give the prime factorization of .
The first line contains a non-negative integer and a positive integer , separated by spaces.
The next lines each contain two positive integers and , separated by spaces. (It is guaranteed that each is prime and they are pairwise distinct.)
Output Format
One line containing a non-negative integer, representing modulo .
3 2
2 1
5 1
1100
Hint
Constraints
The information for each test point is shown in the table below.
| ID | Special Constraints | |
|---|---|---|
| 1 | ||
| 2 | None | |
| 3 | ||
| 4 | ||
| 5 | , | |
| 6 | ||
| 7 | ||
| 8 | ||
| 9 | None | |
| 10 |
For all test points, it is guaranteed that , , and .
Translated by ChatGPT 5
京公网安备 11011102002149号