rt.前情提要
#include<bits/stdc++.h>
using namespace std;
int a,b;
struct node{
int a,b,step;
};
queue<node> q;
void bfs(){
q.push({a,b,0});
while(!q.empty()){
node f=q.front();
q.pop();
if(f.a==f.b){
cout<<f.step;
return;
}
q.push({f.a*2,f.b,f.step+1});
q.push({f.a,f.b-1,f.step+1});
q.push({f.a,f.b+1,f.step+1});
}
}
int main(){
cin>>a>>b;
bfs();
}