BETA

Difficulty Level:

Easy

Total Submissions: 376 Accuracy:

13.03%

Number and the Digit Sum
         

Given a positive value N, we need to find the count of numbers smaller than and equal to N such that the difference between the number and sum of its digits is greater than or equal to given specific value k.

Input:
The first line of input contains an integer T denoting the number of test cases. Each test case contains two space separated integers N and k.

Output:
Print an integer which is the required value.

Constraints:
1<=T<=50
1<=N,k<=109

Example:
Input:

2
13 2
10 5

Output:
4
1

Explanation:

Input : N = 13, diff = 2
Output : 4
Then 10, 11, 12 and 13 satisfy the given
condition shown below,
10 – sumofdigit(10) = 9 >= 2
11 – sumofdigit(11) = 9 >= 2
12 – sumofdigit(12) = 9 >= 2
13 – sumofdigit(13) = 9 >= 2  
Whereas no number from 1 to 9 satisfies 
above equation so final result will be 4

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Shashwat Jain

Set Default Code

					   
It is recommended to 'Compile & Test' your code before clicking 'Submit'!

Compilation/Execution Result:

Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.