#P16209. [ECUSTPC 2025] 眼见为实
[ECUSTPC 2025] 眼见为实
Problem Description
Maddy and Baddy are having a battle of minds.
Baddy has a hidden number in mind, and satisfies the following rules:
- is a natural number.
- .
- The remainder when is divided by is , and the remainder when is divided by is .
Now Maddy knows . Please help her find a possible value of that Baddy might be thinking of. If no possible answer exists, report that there is no solution.
Input Format
One line contains integers (), representing the range of Baddy’s number, the remainder when divided by , and the remainder when divided by , respectively.
Output Format
If a valid answer exists, output one integer in one line, representing the number Baddy is thinking of. If there are multiple valid answers, you may output any one of them.
If no possible answer exists, output one integer in one line.
0 1 2
5
63 1 1
67
Hint
Explanation for Sample 1
Check the above properties one by one:
- is a natural number.
- .
- The remainder when is divided by is , and the remainder when is divided by is .
Therefore, satisfies the conditions of the number Baddy is thinking of, and it is a possible value.
Hint
is a natural number.
Translated by ChatGPT 5