Accepted
/in/foo.cc: In function 'int main()': /in/foo.cc:28:22: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long long int' [-Wformat=] printf("%d\n",total); ^
代码
#include <cstdio>
#include <queue>
std::queue<int> stack;
int main()
{
int n;
scanf("%d",&n);
for(int i=0;i<n;i++){
int from,to;
scanf("%d%d",&from,&to);
while(from>0){
stack.push(from);
from>>=1;
}
long long total=0;
while(to>0){
while(stack.front()>to){
stack.pop();
total++;
}
if(stack.front()==to) break;
total++;
to>>=1;
}
while(!stack.empty()) stack.pop();
printf("%d\n",total);
}
return 0;
}