#P17454. 迭代不动点 / Iterated Fixed Points
迭代不动点 / Iterated Fixed Points
Problem Description
Due to differences in the performance of the judging machines, the time limit of this problem has been adjusted to 2 s.
Given three integers .
Consider all functions
Let denote the -th iteration of the function . If satisfies
then is called a -th order iterated fixed point of .
Find the number of functions that have exactly -th order iterated fixed points. Output the answer modulo .
Input Format
This problem contains multiple test cases.
The first line contains an integer , indicating the number of test cases.
The next lines each contain three integers .
It is guaranteed that the sum of over all test cases does not exceed .
Output Format
For each test case, output one integer per line, representing the result modulo .
7
3 2 2
2 1 0
3 1 0
3 2 0
3 3 3
4 2 4
4 1 2
12
1
8
2
3
10
54
Hint
Translated by ChatGPT 5