|시간 제한||메모리 제한||제출||정답||맞은 사람||정답 비율|
|5 초||512 MB||1||1||1||100.000%|
Shekhu has N balls. She wants to distribute them among one or more buckets in a way that satisfies all of these constraints:
How many different ways are there for Shekhu to do this? Two ways are considered different if the lists of numbers of balls in buckets, reading left to right, are different.
The first line of the input gives the number of test cases, T.
T test cases follow. Each test case consists of one line with two integers N and D, as described above.
For each test case, output one line containing Case #x: y, where x is the test case number (starting from 1) and y is the answer, as described above.
3 7 1 7 2 2 4
Case #1: 10 Case #2: 1 Case #3: 0
In sample case #1, the possible distributions are:
Note that 1 2 4 is not a valid distribution, since the difference between 1 and 4 is more than 2.
In sample case #2, the possible distributions are:
3 4 is not possible, since the first term is not divisible by 2.
In sample case #3, no possible arrangement exists.