Accepted
代码
#include<bits/stdc++.h>
using namespace std;
int dx,dy,n;
int main()
{
int n;
cin>>n;
while (n--)
{
int x,y;
cin>>x>>y;
dx=log2(x);
dy=log2(y);
if (dx<dy) swap(dx,dy),swap(x,y);
int ans=0;
for (int i=dx;i>=dy+1;i--)
x/=2,ans++;
for (int i=dy;i>=0;i--)
{
if(x==y)break;
x/=2,y/=2;ans+=2;
}
cout<<ans<<endl;
}
}