Sum and XOR
Easy
Execution time limit is 1 second
Runtime memory usage limit is 128 megabytes
On the very usual day of spring, Daniyar is challenged with an interesting problem once again:
You need to find all possible arrays of length n where each element 1 ≤ a[i]
< 2^(number_of_bits)
, 0 ≤ i < n with the following conditions:
Sum of the array is equal to sum, i.e.
a[0]
+a[1]
+ ... +a[n - 1]
= sum.XOR sum of the array is equal to xor_sum, i.e.
a[0]
xora[1]
xor ... xora[n - 1]
= xor_sum.
To simplify, you are asked to find the answer modulo 10^9
+ 9.
Input
A single line contains 4 integers:
n (1 ≤ n ≤ 5000),
sum (1 ≤ sum ≤ 3000),
number_of_bits (1 ≤ number_of_bits ≤ 30),
xor_sum (1 ≤ xor_sum <
2^(number_of_bits)
).
Output
Output the answer to the problem modulo 10^9
+ 9.
Example
In the first sample test, there are two possible arrays: {5, 7}, {7, 5}.
Examples
Input #1
Answer #1
Input #2
Answer #2
Input #3
Answer #3
Input #4
Answer #4
Submissions 73
Acceptance rate 26%