CodeChef May Long Challenge Solution | Xor Equality (XOREQUAL) solution | AskTheCode
Xor Equality (XOREQUAL) solution in C++
Problem:
For a given N, find the number of ways to choose an integer x from the range [0,2^N − 1] such that x ⊕ (x+1) = (x+2) ⊕ (x+3), where ⊕ denotes the bitwise XOR operator.
Since the number of valid x can be large, output it modulo 10^9+7.
Input:
The first line contains an integer T, the number of test cases. Then the test cases follow.
The only line of each test case contains a single integer N.
Output:
For each test case, output in a single line the answer to the problem modulo 10^9+7.
Sample Input:
2
1
2
Sample Output:
1
2
Explanation:
Test Case 1: The possible values of x are {0}.
Test Case 2: The possible values of x are {0,2}.
Code:
We have uploaded the solution, but it is kept private only for members, to prevent the reach of Codechef. Kindly visit our AskTheCode Members Group to see the code. Or you can also click here to see the solution in C++.
Be active here at AskTheCode because we'll be uploading the solutions of rest problems at any time. If you want the solutions to be uploaded sooner, kindly do clicks on the relevant ads here. We will upload the next solutions only after 50 adClicks on this post.
Hope you guys could help us to achieve that target🙂.
コメント