Integer Partition

Time Limit: 1000ms
Memory Limit: 32768KB
This problem will be judged on HDU. Original ID: 4658
64-bit integer IO format: %I64d      Java class name: Main

Description

Given n, k, calculate the number of different (unordered) partitions of n such that no part is repeated k or more times.

Input

First line, number of test cases, T.
Following are T lines. Each line contains two numbers, n and k.

1<=n,k,T<=105

Output

T lines, each line contains answer to the responding test case.
Since the numbers can be very large, you should output them modulo 109+7.

Sample Input

4
4 2
4 3
4 4
4 5

Sample Output

2
4
4
5

Source

Language: 
Theme: 
Share Code? 

Powered by NB231 | Current Style: .