Super calculator
Super calculator
Supercalculator performsonly a singlearithmetic operation- multiplicationof natural numbers.The upper limit ofthe range ofrepresentationsof natural numbersin the calculatoris not known.We denotethis boundaryP. If the result isgreater thanor equal to themultiplication ofP (a·b ≤ P, a, b - factors), thetwo situations are possible:
- The answeris(a·b) mod P .
- The answer -a random numberin the rangeof valid values (malfunctioningcalculator).
Giventhe values ofthe factors (a, b) and result (c). Requiredto write a programanalysis ofthe calculator,which results in asingle numberthat is generatedby the following principle:
- 0, if c = a·b;
- 1, if thefailure occurred;
- the minimum value ofP.
Input
The stringcontains thenumbersa, b and cseparated by a space, a and b – factors, c – the result.
Output
This file containsa single number.
Note: small Vasya, who dreams of becoming a hacker managed to spy on the length of the line input does not exceed 15.
4 5 20
0