Count of n digit numbers whose sum of digits equals to given sum
Submissions: 9346   Accuracy:

21.79%

  Difficulty: Medium   Marks: 4

Given two integers ‘n’ and ‘sum’, find count of all n digit numbers with sum of digits as ‘sum’. Leading 0’s are not counted as digits. Print your output % 10^9+7.

Input:
The first line contains an integer T, depicting total number of test cases. 
Then following T lines contains 2 integers n and sum.

Output:
Print the number of digits. Print -1 if answer is not possible.

Constraints:
1<=T<=30
1<=n<=100
1<=sum<=1000

Example:
Input:
1
2 2

Output:
2

Explaination:  2 numbers 11 and 20.

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

Author: abhiraj26


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



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


to report an issue on this page.