#include<bits/stdc++.h>
using namespace std;
int dx[3]={1,-1};
struct node{
int x,t;
};
queue <node> q;
bool vis[100001];
int n,k;
void bfs(int sx)
{
int ans=0x3f;
node h,t;
t={sx,0};
q.push(t);
vis[sx]=true;
while(!q.empty())
{
h=q.front();
q.pop();
dx[2]=h.x;
for(int i=0;i<=2;i++)
{
int nx=h.x+dx[i];
int nt=h.t+1;
if(nx==k)
ans=min(ans,nt);
if(nx>=0 && nx<=100000 && !vis[nx])
{
t={nx,nt};
q.push(t);
vis[nx]=true;
}
}
}
cout<<ans;
}
int main()
{
cin>>n>>k;
bfs(n);
return 0;
}
http://ybt.ssoier.cn:8088/problem_show.php?pid=1253
快疯了(我好菜