Is There a Divisor?
Time limit2sMemory limit512 MB
Given a digit string, find a base B and a divisor X (both at most 10^9) making the string's value composite in base B, or report that none exists.
- Level
Medium6 of 10
- Topics
- Math, Number theory, String, Brute force
- Solved
- No attempts yet
Problem
A forum that discusses informatics olympiad problems introduced the following captcha. A participant is given a string of decimal digits (with no leading zeros). In reply, the participant must enter a base such that in this base the given record represents a composite number (call it ), along with a number that is greater than 1, less than , and a divisor of .
Here and must not exceed .
Given a string of decimal digits, find any pair of numbers and that satisfies the constraints, or report that no solution exists within the given constraints.
Input
The input consists of a single non-empty string of at most characters made up of digits from 0 to 9 that does not begin with 0.
Output
If a solution exists, output two numbers: the base and the divisor , written in decimal. Both numbers must satisfy . If no solution exists, output .