#P8795. [蓝桥杯 2022 国 A] 选素数
[蓝桥杯 2022 国 A] 选素数
Problem Description
Xiao Lan has a number . In each operation, Xiao Lan chooses a prime that is less than , then keeps increasing by until becomes a multiple of (if is already a multiple of at the beginning, then stays unchanged).
Xiao Qiao saw the result obtained after Xiao Lan performed the above operation twice, and he wants to know what was at the beginning. If there are multiple possibilities, he wants to know the minimum possible initial value of . If there is no solution, it means Xiao Qiao saw it wrong; in this case, output .
Input Format
The input contains one line with an integer , representing the value of after two operations.
Output Format
Output one line with an integer representing the initial value of . If there are multiple solutions, output the smallest one. If there is no solution, output .
22
8
Hint
Constraints
- For of the testdata, .
- For all testdata, .
Lanqiao Cup 2022 National Contest Group A Problem G.
Translated by ChatGPT 5