And
Time limit2sMemory limit512 MB
Count K-term non-negative integer sequences whose bitwise AND decreases monotonically and whose terms sum to N, modulo 1e9+7.
- Level
Medium7 of 10
- Topics
- Bit manipulation, Dynamic programming, Combinatorics
- Solved
- No attempts yet
Problem
Two integers and are given. Your task is to find the number of sequences with terms. A sequence must satisfy the following conditions.
- (bitwise AND),
Input
The first line gives a single positive integer , the number of test cases.
Each of the next lines gives two positive integers and .
Output
Print the answer for each test case on one line. The answer can be very large, so print it modulo .