#P5668. 【模板】N 次剩余
【模板】N 次剩余
Description
You need to solve the equation , where .
Input Format
The first line contains a positive integer , the number of test cases.
Each test case contains three positive integers .
Output Format
For each test case, output one or two lines:
The first line contains the number of distinct solutions .
If , then output a second line with integers, in increasing order, listing all possible solutions separated by spaces.
It is guaranteed that .
2
3 531441 330750
5 304128 1
27
264 19947 39630 59313 78996 98679 118362 138045 157728 177411 197094 216777 236460 256143 275826 295509 315192 334875 354558 374241 393924 413607 433290 452973 472656 492339 512022
5
1 82945 138241 165889 193537
Hint
For of the testdata, , , .
Let the unique factorization of be . It is guaranteed that the number of solutions to in is .
Translated by ChatGPT 5
京公网安备 11011102002149号