Ankit and Race Team
Practice
5 (1 votes)
Combinatorics
Mathematics
Medium
Open
Approved
Problem
41% Success 2652 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code

Coach Ankit is forming a team for the Annual Inter Galactic Relay Race. He has N students that train under him and he knows their strengths. The strength of a student is represented by a positive integer.

The coach has to form a team of K students. The strength of a team is defined by the strength of the weakest student in the team. Now he wants to know the sum of strengths of all the teams of size K that can be formed modulo 1000000007. Please help him.

Input
The first line contains the number of test cases T.
Each case begins with a line containing integers N and K. The next line contains N space-separated numbers which describe the strengths of the students.

Output
For test case output a single integer, the answer as described in the problem statement.

Constraints:
1<=T<=100
1<=N<=100000
1<=K<=N
0<=Strength of each student<=2000000000
Strength of all the students are different.

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
2 votes
Tags:
CombinatoricsMathematicsMediumOpenApproved
Points:30
Tags:
AlgorithmsMediumOpenApprovedMathematics