Problem F. Clever Y

时间限制 5000 ms   内存限制 64 MB

Little Y finds there is a very interesting formula in mathematics:

XY mod Z = K

Given X, Y, Z, we all know how to figure out K fast. However, given X, Z, K, could you figure out Y fast?


输入数据

Input data consists of no more than 20 test cases. For each test case, there would be only one line containing 3 integers X, Z, K (0 ≤ X, Z, K ≤ 10 9).
Input file ends with 3 zeros separated by spaces.

输出数据

For each test case output one line. Write "No Solution" (without quotes) if you cannot find a feasible Y (0 ≤ Y < Z). Otherwise output the minimum Y you find.

样例输入

复制
5 58 33
2 4 3
0 0 0

样例输出

复制
9
No Solution

提交

请先 登录

© 2025 FAQs Contact About