#Q216. 「一本通 6.4 例 6」计算器
「一本通 6.4 例 6」计算器
Description
Original source: SDOI 2011
You are asked to design a calculator to perform the following three tasks:
- Given , compute the value of ;
- Given , compute the smallest non-negative integer such that ;
- Given , compute the smallest non-negative integer such that .
Input Format
The input contains multiple test cases.
The first line contains two positive integers representing the number of test cases and the query type (for all data within a test case, the query type is the same);
Each of the next lines contains three positive integers , describing a query.
Output Format
For each query, output one line with the answer.
For query types and , if there is no solution, output Orz, I cannot find x!. Note there is a space between the comma and I.
Sample 1
3 1
2 1 3
2 2 3
2 3 3
2
1
2
Sample 2
3 2
2 1 3
2 2 3
2 3 3
2
1
0
Data Range and Hints
For all data, , and it is guaranteed that is a prime number.