実行時間制限: 2 sec / メモリ制限: 1024 MB
配点 : 300 点
問題文
整数 A, B が与えられます。整数 x, y を A ≤ x < y ≤ B となるように選ぶときの、\gcd(x, y) の最大値を求めてください。
なお、\gcd(x, y) は x と y の最大公約数を表します。
制約
- A, B は整数
- 1 ≤ A < B ≤ 2 \times 10^5
入力
入力は以下の形式で標準入力から与えられる。
A B
出力
答えを出力せよ。
入力例 1
2 4
出力例 1
2
A ≤ x < y ≤ B を満たす (x,y) の選び方は (2,3), (2,4), (3,4) の 3 つです。それぞれ最大公約数は 1, 2, 1 であるので、最大値は 2 です。
入力例 2
199999 200000
出力例 2
1
\gcd(199999, 200000) = 1 です。
入力例 3
101 139
出力例 3
34
Score : 300 points
Problem Statement
Given are integers A and B. Find the maximum possible value of \gcd(x, y) when we choose integers x and y so that A ≤ x < y ≤ B.
Here, \gcd(x, y) denotes the greatest common divisor of x and y.
Constraints
- A and B are integers.
- 1 ≤ A < B ≤ 2 \times 10^5
Input
Input is given from Standard Input in the following format:
A B
Output
Print the answer.
Sample Input 1
2 4
Sample Output 1
2
We have three ways to choose (x, y) such that A ≤ x < y ≤ B: (2,3), (2,4), (3,4), where the greatest common divisors are 1, 2, 1, respectively, so the maximum possible value is 2.
Sample Input 2
199999 200000
Sample Output 2
1
We have \gcd(199999, 200000) = 1.
Sample Input 3
101 139
Sample Output 3
34