#P11253. [GDKOI2023 普及组] 小学生数学题
[GDKOI2023 普及组] 小学生数学题
Problem Description
Moon is an elementary school student. While doing homework, he encountered the following problem: given positive integers , find the value of the expression:
Here, denotes the factorial of , that is, . This expression is too hard, so Moon hopes to get your help. However, since Moon has only learned integer operations and has not learned real-number operations, he wants you to help him compute the value of this expression modulo . That is, if the final result can be simplified into an irreducible fraction , you only need to output , where is the modular inverse of modulo .
Input Format
The first line contains two integers .
Output Format
One line with one integer, representing the answer modulo .
5 1
34
100 100
523011929
10000000 10000000
686183373
Hint
Sample Explanation
In sample , since , the original expression is equivalent to .
Constraints
For all testdata, .
For of the testdata, .
For another of the testdata, .
Translated by ChatGPT 5