cswork / OA打开练习工作台

其他OA #14

Minimum Extra Chocolates

估计中等可在线判题

考点(AI 标注)位运算

Add a non-negative number of chocolates to each of the two boxes so that Drake's total becomes a positive integer multiple of Alex's total, and find the minimum total added. This site makes k≥1, X,Y≥0 and the ranges explicit.

输入格式

One line with two positive integers A and B (1≤A,B≤10^9).

输出格式

Output the minimum non-negative integer X+Y such that some positive integer k satisfies k(A+X)=B+Y.

样例 1

输入:

8 16

输出:

0

样例 2

输入:

7 37

输出:

4

样例 3

输入:

70 229

输出:

9