Again About Prime Numbers
Very easy
Execution time limit is 1 second
Runtime memory usage limit is 64 megabytes
Find a prime number within the range [a; b] that has the highest sum of its digits. If multiple numbers share the highest digit sum, select the largest prime among them.
A prime number is defined as a natural number greater than one that is divisible only by one and itself.
Input
The input consists of two integers: a and b (1 ≤ a ≤ b ≤ 10^8), with the condition that b-a ≤ 1000.
Output
Output the solution to the problem. If there are no prime numbers within the specified range, output -1.
Examples
Input #1
Answer #1
Submissions 869
Acceptance rate 25%