#include<bits/stdc++.h> using namespace std; int n,m; struct Node{ int x,step; }; queue<Node> q; bool panduan(int x,int step){ if(x==m){ cout<<step; return true; } else{ q.push({x,step}); return false; } } int main(){ cin>>n>>m; while(!q.empty()){ int x=q.front().x; int step=q.front().step; bool f=false; f=f||panduan(x+1,step+1); f=f||panduan(x-1,step+1); f=f||panduan(x*2,step+1); if(f) return 0; q.pop(); } return 0; } /************************************************************** Problem: 2111 User: caijiajie Language: C++ Result: Wrong Answer ****************************************************************/