Ways to sum to N
Submissions: 1639   Accuracy:


  Difficulty: Easy   Marks: 2

Given a set of m distinct positive integers and a value ‘N’. The problem is to count the total number of ways we can form ‘N’ by doing sum of the array elements. Repetitions and different arrangements are allowed.



The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. The first line of each test case contains M and N where M denotes the size of the array and we have to find the answer for the number N.

The second line of each test case contains M space separated integers denoting elements of the array A[ ].


Print the answer for each test case in a new line. Since the answer can be quite large output the answer modulo 109+7.


1<= M <=1000

1<= N <=1000

1<= A[ ] <=1000




3 7

1 5 6



** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Sujnesh Mishra
Author: sujnesh

Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.

to report an issue on this page.