Binod Codechef solutions Today | Codechef Starters 65✅ (100/100) FULL | AC Code ✅| BIN_OD
IF ANYONE DONE THIS AND IS YOU WANT TO HELP SO JUST WRITE DOWN CODE IN COMMENTS
For Solution
“Coming Soon After 10 Minutes“
#include <iostream>
using namespace std;
int main() {
int t;
cin>>t;
while(t--){
int n;
int q;
cin>>n>>q;
int
for(int
long long x;
cin>>x;
for(int j=0;j<64;j++){
for(int i=0;i<64;i++){
int count=0;
for(int
count+=a[i][j];
a[i][j]=count;
int 11
cin>>k>>ll >>rl >>12>>r2;
int totalf=rl -11+1 ;
int totals=r2-12+1 ;
int totalfo:
int totalso;
else
else
long sum = (long)(totalf-totalfo)*(long)(totalso) + (long
(totalfo)*(long)(totals-totalso);
cout<<sum<<endl;
return 0;
Problem
A Binod is a person who is very good with bitwise operations. Help Alice solve the following problem and become a Binod.
You are given an array of elements. Process queries on this array, of the following form:
- Each query contains integers . It is guaranteed that .
- The answer to a query is the number of pairs such that:
- and
- has its -th bit set. Here denotes the bitwise XOR operation.
Note: An integer is said to have its -th bit set if the (unique) binary representation of contains . For example, has its zeroth and second bits set but not the first, while has only its fourth bit set.
Input Format
- The first line of input will contain a single integer , denoting the number of test cases.
- Each test case consists of multiple lines of input.
- The first line of each test case contains two space-separated integers and — the number of elements in array and number of queries, respectively.
- The second line of each test case contains space-separated integers .
- The next lines describe queries. The -th of these lines contains space-separated integers — the parameters described in the statement.
Output Format
For each test case, output lines.The -th of these lines should be the answer to the -th query.
Constraints
- .
- The sum of and over all test cases won't exceed and respectively.
Sample 1:
Input
Output
2 5 2 1 2 4 3 2 1 1 3 5 5 2 1 2 3 5 6 2 3 5 6 13 12 20 1 1 4 5 6 3 2 3 4 6
2 2 4 4
Explanation:
Test case : The array is .
- Query : the ranges are and , and . There are three pairs of : .
- has its first bit set
- doesn't have its first bit set
- has its first bit set
- So, the answer is .
- Query : the ranges are and , and now . This time, there are pairs of indices. Of them, it can be verified that and are the ones that satisfy the given condition.