delete pics to save space

This commit is contained in:
2023-08-03 09:22:52 +08:00
commit de60cd6ed4
1334 changed files with 66221 additions and 0 deletions

View File

@ -0,0 +1,34 @@
#include<cstdio>
#include<queue>
using namespace std;
int ans[133334]={0},n,k,x;
int main()
{
queue<int>q;
scanf("%d%d",&n,&k);
q.push(n);
ans[n]=1;
do
{
x=q.front();
if(x>0&&ans[x-1]==0)
{
ans[x-1]=ans[x]+1;
q.push(x-1);
}
if(x<k&&ans[x+1]==0)
{
ans[x+1]=ans[x]+1;
q.push(x+1);
}
if(x*3<=k*2&&ans[x*2]==0)
{
ans[x*2]=ans[x]+1;
q.push(x*2);
}
q.pop();
}
while(ans[k]==0);
printf("%d\n",ans[k]-1);
return 0;
}