Problem E. Description has only two Sentences

时间限制 1000 ms   内存限制 32 MB

a n = X*a n-1 + Y and Y mod (X-1) = 0.
Your task is to calculate the smallest positive integer k that a k mod a 0 = 0.
 

输入数据

Each line will contain only three integers X, Y, a 0 ( 1 < X < 2 31, 0 <= Y < 2 63, 0 < a 0 < 2 31).
 

输出数据

For each case, output the answer in one line, if there is no such k, output "Impossible!".
 

样例输入

复制
2 0 9

样例输出

提交

请先 登录

© 2025 FAQs Contact About