这道题目是一个最短路

#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>


#define int long long 


const int N=100010;
int n,k;
int q[N];
int dist[N];
int bfs()
{
	memset(dist,-1,sizeof dist);
	dist[n]=0;
	q[0]=n;
	int hh=0;
	int tt=0;
	while(hh<=tt)
	{
		int t=q[hh++];
		if(t==k)
		{
			return dist[k];
		}
		if(t+1<N&&dist[t+1]==-1)
		{
			dist[t+1]=dist[t]+1;
			q[++tt]=t+1;
		}
		if(t-1>=0&&dist[t-1]==-1)
		{
			dist[t-1]=dist[t]+1;
			q[++tt]=t-1;
			
		}
		if(t*2<N&&dist[t*2]==-1)
		{
			dist[t*2]=dist[t]+1;
			q[++tt]=t*2;
		}
	}
	return -1;
	
}
using namespace std;
signed main()
{
	cin>>n>>k;
	cout<<bfs()<<"\n";
	return 0;
	
}