#t292. 确定进制
确定进制
Determine the Base
Problem Background
Special for beginners, ^_^
Problem Description
is wrong in decimal, but correct in base , i.e.
and
Your task is to write a program that reads three integers , , and , then determines a base such that . If there are multiple choices for , output the smallest one. For example: . Then
because
and
$$121_3 = 1 \times 3^2 + 2 \times 3^1 + 1 \times 3^0 = 16_{10}$$For base , we have
In this case you should output . If no suitable base exists, output .
Input Format
One line containing three integers , , , separated by single spaces. All digits of , , are decimal digits, and .
Output Format
One integer: the smallest such that holds. If no suitable exists, output .
Sample Input
6 9 42
Sample Output
13
Constraints
1s, 1024KiB for each test case.