Binomial coefficient queries
Time limit1sMemory limit512 MB
Given M pairs N and K, print the binomial coefficient C(N, K) modulo 1,000,000,007.
- Level
Medium5 of 10
- Topics
- Combinatorics, Math, Prefix sum
- Solved
- No attempts yet
Problem
You are given pairs, each made of a positive integer and an integer . For every pair, compute the binomial coefficient modulo 1,000,000,007.
Input
The first line contains the number of pairs ().
Each of the next lines contains and , separated by a space (, ).
Output
Print lines. On the -th line, print modulo 1,000,000,007 for the -th pair, in input order.