http://acm.csu.edu.cn/OnlineJudge/showsource.php?id=97234
#include<cstdio> #include<cmath> #include<cstring> #include<iostream> #include<algorithm> using namespace std; int main() { //freopen("output.txt","w",stdout); long long int a,b; long long int temp; int t,n; scanf("%d",&t); while(t--) { scanf("%d%lld%lld",&n,&a,&b); long long int ans=1; for(int i=0;i<n;i++) ans*=2; if(b>a) a=b; int cnt=0; //printf("%lld\n",a); if(a==ans) { printf("0\n"); } else { //cout<<"ddddddddddddd"<<endl; //printf("%lld %lld %lld %d\n",ans,a,temp,cnt); while(a>0) { temp=ans/2; ans=temp; if(a>=temp) a-=temp; cnt++; //printf("%lld %lld %lld %d\n",ans,a,temp,cnt); } } printf("%d\n",cnt); } return 0; }
时间: 2024-12-20 17:08:43