Power Failure
Practice
3.8 (17 votes)
Combinatorics
Dynamic programming
Easy
Math
Number theory
Problem
80% Success 4784 Attempts 20 Points 3s Time Limit 256MB Memory 1024 KB Max Code

Dexter is a young genius. He is so smart that he has built a big laboratory for himself. His rival’s name is Mandark. Dexter’s laboratory has developed a power failure due to a prank played on him by Mandark. He decided to buy batteries to temporarily provide power to his lab. His lab has n machines. The ith machine requires a battery with voltage rating of atleast \(V_i\) volts \((1<=i<=n)\). Dexter went to the local electronics shop. They have one battery of each voltage rating from 1 to M. Dexter is very suspicious of his rival Mandark. He thinks that Mandark has planted bombs in batteries with a prime voltage rating. He doesn’t want those batteries. As his lab computer is not working, Dexter wants you to find out the number of ways he can buy batteries for each of his machines.

Input:

The first line of the input contains t, the number of test cases. t test cases follow.

Each test case consists of two lines. The first line contains n and m. The second line contains n space separated integers denoting \(V_i\).

Output:

For each test case output a single number, that is the answer for that test case. Output the number of ways modulo \(1000000007\; (10^9 + 7)\).

Constraints:

\(1 \le t \le 100\)

\(1 \le m,n,V_i \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:20
6 votes
Tags:
Basic ProgrammingBasics of ImplementationEasyImplementation
Points:20
29 votes
Tags:
Ad-HocAlgorithmsBasic ProgrammingBasics of ImplementationEasyImplementation
Points:20
58 votes
Tags:
ApprovedEasyImplementationOpen