#abc136e. [abc136_e]Max GCD
[abc136_e]Max GCD
Problem Statement
We have a sequence of integers: .
You can perform the following operation between and times (inclusive):
- Choose two integers and such that , each between and (inclusive). Add to and to , possibly producing a negative element.
Compute the maximum possible positive integer that divides every element of after the operations. Here a positive integer divides an integer if and only if there exists an integer such that .
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the maximum possible positive integer that divides every element of after the operations.
Sample Input 1
2 3
8 20
Sample Output 1
7
will divide every element of if, for example, we perform the following operation:
- Choose . becomes .
We cannot reach the situation where or greater integer divides every element of .
Sample Input 2
2 10
3 5
Sample Output 2
8
Consider performing the following five operations:
- Choose . becomes .
- Choose . becomes .
- Choose . becomes .
- Choose . becomes .
- Choose . becomes .
Then, and , so divides every element of . We cannot reach the situation where or greater integer divides every element of .
Sample Input 3
4 5
10 1 2 22
Sample Output 3
7
Sample Input 4
8 7
1 7 5 6 8 2 6 5
Sample Output 4
5