Binomial coefficient 6
Time limit2sMemory limit512 MB
For up to 100,000 queries, compute the binomial coefficient C(N,K) modulo 142857 where N goes up to 1e9.
- Level
Hard8 of 10
- Topics
- Number theory, Combinatorics, Math
- Solved
- No attempts yet
Problem
You are given a positive integer and an integer . Write a program that computes the remainder of the binomial coefficient divided by .
Input
The first line contains the number of test cases . ()
Each of the next lines holds one test case, with and separated by a space. (, )
Output
For each test case, print the remainder of divided by on its own line.