3 条题解
-
1
#include <bits/stdc++.h> #define ll long long using namespace std; ll aa,bb,zx=2147480000,f[2000005]; void work(ll x,ll ans) { if(x>=bb) { zx=min(zx,ans+x-bb); return; } f[x]=1; if(x>1&&f[x-1]==0) work(x-1,ans+1); if(f[x+1]==0) work(x+1,ans+1); if(f[xx]==0&&x!=1) work(xx,ans+1); f[x]=0; } int main() { cin>>aa>>bb; work(aa,0); cout<<zx; return 0; }
信息
- ID
- 20971
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 9
- 标签
- (无)
- 递交数
- 124
- 已通过
- 10
- 上传者