提交时间:2023-01-11 14:37:35

运行 ID: 17576

#include <bits/stdc++.h> using namespace std; int main(){ int x,y,sum=0,si=1; bool step=1; cin>>x>>y; while(1){ if(step==1){ if(x+si>=y and x<y){ sum+=abs(x-y); cout<<sum; break; } step=0; }else{ if(x-si<=y and x>y){ sum+=abs(x-y); cout<<sum; break; } step=1; } sum+=si*2; si*=2; } return 0; }