Counting stars
Practice
4.5 (6 votes)
Approved
Combinatorics
Easy
Math
Ready
Recruit
Approved
Problem
38% Success 1119 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code

There are N stars in the sky. A manual attempt at counting yielded K stars. It is possible that the same star may have been counted more than once. You need to determine the probability that any star may have been counted more than once. Probability can be represented as a rational number \( \frac{\textstyle P}{\textstyle Q} \). If Q is not divisible by \(10^9 + 7\) there is a unique integer \(x \mid 0 \leq x \lt 10^9 +7\) where \( P \equiv Qx\) \(\%\) \((10^9 +7)\). Calculate value of this integer x.

Input Format:
First line of input consists of a single integer T denoting number of test cases.
Following T lines contain two space separated integers denoting N and K.

Output Format:
Print the answer to each test case in a new line.

Input Constraints:
\(1 \le T \le 10\)
\( 1 \le N, K \le 100000\)

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:30
8 votes
Tags:
CombinatoricsEasyMath
Points:30
5 votes
Tags:
CombinatoricsEasyMath
Points:30
3 votes
Tags:
CombinatoricsEasyFibonacci numberMath