#P5702. 调和级数求和
调和级数求和
Description
Given , find the value of:
modulo .
If you do not know how to take a fraction modulo a number, you can refer to this problem.
It is guaranteed that the answer exists modulo .
To make your computation easier, the smallest primitive root of will be provided.
Input Format
The first line contains a positive integer , the number of test cases.
The next lines each contain three positive integers .
Output Format
Output lines. Each line contains one integer, the answer.
5
998007 998244353 3
19260817 998244353 3
274829164 998244353 3
792846153 998244353 3
1924762 899678209 7
429767635
632288905
445668022
128133635
3097708
Hint
Constraints
For of the testdata, .
For of the testdata, , .
It is guaranteed that is prime, and is divisible by .
Note: The time limit is three times that of std. If you cannot pass, please check that your time complexity is correct and optimize the constant factors.
Translated by ChatGPT 5
京公网安备 11011102002149号