1234 - Minimum Power
Time Limit : 1 Second
Memory Limit : 128 MB
Submission: 198
Solved: 65
- Description
- Mike is learning number theory recently, and he has found a beautiful formula: .
Now given A, N, Z, can you find minimum nonnegative L that satisfies the formula? - Input
- First line a integer T indicating the number of the test cases.
Next T line, each line contains three integers A, N, Z, refer to the description.
Note that Z may not be a prime
( 0 <= A , N <= 2,147,483,647 ), ( 2 <= Z <= 2,147,483,647 )
- Output
- For each test case output one line.
Write “No Solution” if you cannot find a feasible L(0 <= L < Z), otherwise output the minimum L you find. - sample input
-
2 5 33 58 2 3 4
- sample output
-
9 No Solution
- hint
- source