-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQ5
More file actions
68 lines (45 loc) · 1.29 KB
/
Q5
File metadata and controls
68 lines (45 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
--------------------------------------------
Problem Statement:
Two positive integers called a and b are given you. In one move you can increase a by 1 (replace a with a+1). You task is to find the minimum number of moves you need to do in otder to make a divisible by b. It is possible, that you have to make 0 moves, as a is already divisible by b.
--------------------------------------------
Input:
The first line of the input contains one integer t — the number of test cases. Then t test cases follow.
The only line of the test case contains two integers a and b.
--------------------------------------------
Output:
Print the answer — the minimum number of moves you need to do in order to make a divisible by b.
--------------------------------------------
Constraints:
1≤t≤10^9
1 ≤ a,b≤ 100000000
--------------------------------------------
Example:
for 100 and 13 output is 4
--------------------------------------------
Test Cases:
Input:
5
10 4
13 9
123 456
92 46
---------------------------------------------
Bug Code:
#include <stdio.h>
using namespace std;
int main()
{
short t;
cin>>t;
int a,b;
while(t--)
{
cin>>a>>b;
cout<<-(a%b);
}
return 0;
}
-------------------
Hint:
Check for Constraints
-------------------