Codeforces Round 554 (Div. 2)
C
Neko does Maths
Codeforces
1800
原题
← BD →
翻译中…

Neko loves divisors. During the latest number theory lesson, he got an interesting exercise from his math teacher.

翻译中…

Neko has two integers $a$ and $b$. His goal is to find a non-negative integer $k$ such that the least common multiple of $a+k$ and $b+k$ is the smallest possible. If there are multiple optimal integers $k$, he needs to choose the smallest one.

翻译中…

Given his mathematical talent, Neko had no trouble getting Wrong Answer on this problem. Can you help him solve it?

翻译中…

Input

翻译中…

The only line contains two integers $a$ and $b$ ($1 \le a, b \le 10^9$).

翻译中…

Output

翻译中…

Print the smallest non-negative integer $k$ ($k \ge 0$) such that the lowest common multiple of $a+k$ and $b+k$ is the smallest possible.

翻译中…

If there are many possible integers $k$ giving the same value of the least common multiple, print the smallest one.

翻译中…

Note

翻译中…

In the first test, one should choose $k = 2$, as the least common multiple of $6 + 2$ and $10 + 2$ is $24$, which is the smallest least common multiple possible.

翻译中…

样例

Input #1
6 10
Output #1
2
InputCopy OutputCopy
Input #2
21 31
Output #2
9
InputCopy OutputCopy
Input #3
5 10
Output #3
0
InputCopy OutputCopy
题目信息
题号
1152C
时间限制
1 s
内存限制
256 MB
标签
暴力
数学
数论

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。