cpp code for : Array Concatanation Count the number of boolean arrays with a a zeroes…
- User
cpp code for : Array Concatanation Count the number of boolean arrays with a a zeroes and b b ones, such that the following holds.
Let A A be the boolean array and A i A i
subarray subarray( A 1 A 1 , A 2 A 2 .... A i A i ). Concatenate A 1 A 1 , A 2 A 2 ... A a + b A a+b and call this array B B. The number of ones on odd and even indexes in the array B B are equal.
Print the answer modulo 1000000007 1000000007.
Note: a a + b b is always even.
Input Format The first line of input will contain a single integer T T, denoting the number of test cases. Each test case consists of one line of input. The first line and only line of each test case contain two integers a a and b b. Output Format For each test case, output on a new line the answer to the problem.
Constraints 1 ≤ T ≤ 100 1≤T≤100 0 ≤ a ≤ 2 ∗ 1 0 6 0≤a≤2∗10 6
0 ≤ b ≤ 2 ∗ 1 0 6 0≤b≤2∗10 6
a + b
0 a+b>0 a + b a+b is even. The sum of a + b a+b over all test cases won't exceed 2 ⋅ 1 0 6 2⋅10 6 . Sample 1: Input Output 3 2 2 1 5 1005 2005 2 2 74974562 Explanation: For first sample:-
For array A A [ 1 , 0 , 1 , 0 ] [1,0,1,0]
Array B B becomes [ 1 ] , [ 1 , 0 ] , [ 1 , 0 , 1 ] , [ 1 , 0 , 1 , 0 ] [1],[1,0],[1,0,1],[1,0,1,0] -> [ 1 , 1 , 0 , 1 , 0 , 1 , 1 , 0 , 1 , 0 ] [1,1,0,1,0,1,1,0,1,0]
The number of 1 1's on the odd indexes is 3 3 and the number of 1 1's on the odd indexes is also 3 3. Hence the condition holds for the array A A.
- Assistant