#CCBCMCHIN0000011. Bài toán chia hết (Divisibility Problem)
Bài toán chia hết (Divisibility Problem)
Divisibility Problem
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Given two positive integers and . In one move, you may increase by exactly . Find the minimum number of moves needed to make the resulting value of divisible by . The answer may be if is already divisible by .
Input
A single line contains two integers and .
Output
Print one integer: the minimum number of moves needed.
Subtasks
- Subtask 1 (20 points): .
- Subtask 2 (30 points): .
- Subtask 3 (50 points): .
Examples
Example 1
Input
10 4
Output
2
Explanation
For a = 10 and b = 4, the remainder a % b is 2. The minimum increment to the next multiple is 2, so the program prints 2.
Example 2
Input
92 46
Output
0
Explanation
For a = 92 and b = 46, the remainder a % b is 0. The minimum increment to the next multiple is 0, so the program prints 0.