You are viewing a single comment's thread. Return to all comments →
using cyclic property #include <bits/stdc++.h> using namespace std; #define int long long #define endl '\n' #define ld long double const int mod = 1e9 + 7; /* #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> */ void solve(){ int n; cin>>n; int a,b; while(n--){ cin>>a>>b; int ans=0; int dif = b-a+1; for(int i=0;i<=32;i++){ int c1 = a & (1LL<<i); int c2 = b & (1LL<<i); if(c1 && c2){ //cout<<i<<"bit"<<endl; int c = (1LL<<i); if(c>=dif){ ans=ans|(1LL<<i); } } } cout<<ans<<endl; } } signed main() { ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); int t; //cin>>t; //while(t--){ solve(); //} return 0; }
Seems like cookies are disabled on this browser, please enable them to open this website
AND Product
You are viewing a single comment's thread. Return to all comments →