Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
as
#include<bits/stdc++.h> using namespace std; #define mem(A) memset(A,0,sizeof(A)) #define loop(i,a,n) for(i=a;i<n;i++) #define pb push_back #define mkp make_pair typedef long long ll; int main() { //freopen("input.txt", "r", stdin); ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); long t,a,b,l=0,x,y; cin>>t; while(t--) { l=0; cin>>a>>b; if(a!=0 && b==0) cout<<"-1"; else if(a!=0 && b==1) cout<<"-1"; else if(a==b) cout<<"0"; else { x=__builtin_popcountll(a); y=__builtin_popcountll(b); while(b) { if(b&1==1) break; l++; b=b>>1; } if(x<y) { cout<<y-x+l; } else if(x>y) { if(y==1) cout<<2; else cout<<1+l; } else { if(y==1) cout<<2; else cout<<l; } } cout<<endl; } }
run
|
edit
|
history
|
help
0
Find value in sorted matrix
Network UVa
cotton farm 0.0.1.0
Shared lock
30 აპრილი
strict aliasing
Test Swap Functions
hilbert
СП КИ ЭТАП 2
Pac update