Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define ll long long
- ll bitvalue(ll x, ll y){
- for (int i=0; i<y; i++){
- x=x/2;
- }
- return x%2;
- }
- int main() {
- ios_base::sync_with_stdio(false);
- cin.tie(nullptr);
- cout.tie(nullptr);
- int t;
- cin>>t;
- while(t--){
- ll n,q;
- cin>>n>>q;
- ll a[n];
- for (ll i=0; i<n; i++) cin>>a[i];
- for (ll z=0; z<q; z++){
- ll k,l1,r1,l2,r2;
- cin>>k>>l1>>r1>>l2>>r2;
- ll e=0;
- for (ll i=l1-1; i<r1; i++){
- for (ll j=l2-1; j<r2; j++){
- if (bitvalue(a[i],k)!=bitvalue(a[j],k)){
- e++;
- }
- }
- }
- cout<<e<<"\n";
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement