1072: The number of ways (recursion)
[Creator : ]
Description
Given list of N integers and an integer K, find the number of ways to calculate the value of K using those numbers with only addition and subtraction operations.
Input
The first line contains 2 integers N and K
the next line contains N integers
the next line contains N integers
Output
one integer
Sample Input Copy
4 2
1 3 2 6
Sample Output Copy
5
HINT
In the example case: N = 4 K=2
we have:
2
-1 -3 + 6 = 2
-1 + 3 = 2
1-2+3=2
1-2-3+6 = 2
There are 5 ways to get 2
we have:
2
-1 -3 + 6 = 2
-1 + 3 = 2
1-2+3=2
1-2-3+6 = 2
There are 5 ways to get 2