Digit Removal solution codechef
-
For Solution
Click Here!
You are given an integer NN and a digit DD. Find the minimum integer you should add to NN such that the final value of NN does not contain the digit DD.
Digit Removal solution codechef
- The first line contains TT denoting the number of test cases. Then the test cases follow.
- Each test case contains two integers NN and DD on a single line denoting the original number and the digit you need to avoid.
Output Format
For each test case, output on a single line the minimum integer you should add to NN.
Digit Removal solution codechef
- 1≤T≤1051≤T≤105
- 1≤N≤1091≤N≤109
- 0≤D≤90≤D≤9
Digit Removal solution codechef
- Subtask 1 (100 points): Original constraints
Sample Input 1
5
21 5
8 8
100 0
5925 9
434356 3
Digit Removal solution codechef
0
1
11
75
5644
Digit Removal solution codechef
Test case 11: N=21N=21 does not contain the digit D=5D=5. Hence there is no need to add any integers to NN.
Test case 22: If 11 is added to N=8N=8, it becomes equal to 99, which does not contain the digit D=8D=8.
Test case 33: The minimum integer you should add to N=100N=100 such that the final value of NN does not contain the digit D=0D=0 is 1111.
Test case 55: The minimum integer which is greater than 434356434356 and does not contain the digit D=3D=3 is 440000440000. So we should add 440000−434356=5644440000−434356=5644.
-
For Solution
Click Here!