Mystical Numbers CodeChef Solution | CodeChef Problem Solution 2022
A number is said to be a Mystical Number with respect to a number if .
You are given an array of size . You are also given queries. Each query consists of three integers , , and .
For each query, find the count of Mystical Numbers in the subarray with respect to the number .
Solution Click Below:- CLICK HERE
Notes:
- represents the Bitwise XOR operation and represents the Bitwise AND operation.
- denotes the subarray .
Input Format
- The first line contains a single integer - the number of test cases. Then the test cases follow.
- The first line of each test case contains an integer - the size of the array .
- The second line of each test case contains space-separated integers denoting the array .
- The third line of each test case contains an integer - denoting the number of queries.
- The of the next lines contains three space-separated integers , and .
Output Format
For each testcase,
- For each query, print in a new line, the count of Mystical Numbers among with respect to the number .
Constraints
- Sum of over all test cases does not exceed .
- Sum of over all test cases does not exceed .
Sample Input 1
1
5
1 2 3 4 5
2
1 5 4
2 5 2
Sample Output 1
3
2
Explanation
Test case :
- Query : .
- .
- .
- .
- .
- .
Mystical numbers are and with respect to . Therefore, the answer to this query is .
- Query : .
- .
- .
- .
- .
Mystical numbers are and with respect to . Therefore , the answer to this query is .
Join Now for Solution:-
No comments:
Post a Comment