#P1708. [入门赛 #21] 星云 hard ver.
[入门赛 #21] 星云 hard ver.
Background
The difference between this problem and the easy ver. is that this problem has multiple test cases.
Look, that cloud, with the stars as its backdrop, is so beautiful.
Problem Description
Define a “nebula number” as a positive integer whose number of digits is not greater than and whose sum of digits is not greater than . Given and , find how many nebula numbers there are.
Input Format
This problem has multiple test cases.
The first line contains an integer , which represents the number of test cases.
For each test case:
The first line contains two integers .
Output Format
For each test case:
Output one integer per line, which is the answer.
2
2 1
3 2
2
9
Hint
Constraints
For of the testdata, .
For of the testdata, , , .
Translated by ChatGPT 5