Catch That Cow
来源:互联网 发布:绝地求生什么时候优化 编辑:程序博客网 时间:2024/06/06 04:23
#include<cstdio>#include<iostream>#include<algorithm>#include<stdio.h>#include<queue>using namespace std;int n;typedef pair<int,int> tp;queue <tp> pp;int sn[200010]= {0};int bfs(int m,int s){ if(m>=n) return m-n; pp.push(tp(m,s)); while(pp.size()) { if(m<0) continue; tp p=pp.front(); pp.pop(); if(sn[p.first]==0) { sn[p.first] =1; if(p.first==n) return p.second; if(p.first+1<=1+n) pp.push(tp(p.first+1,p.second+1)); if(p.first-1<=1+n) pp.push(tp(p.first-1,p.second+1)); if(p.first*2<=1+n&&p.first!=0) pp.push(tp(p.first*2,p.second+1)); } } return 0;}int main(){ int m; scanf("%d%d",&m,&n); printf("%d",bfs(m,0)); return 0;}
1 0
- POJ3278 Catch That Cow
- Catch That Cow
- Catch That Cow
- poj3278 Catch That Cow
- 3278. Catch That Cow
- 【HDU2717】-Catch that cow
- Catch That Cow
- F - Catch That Cow
- poj3278 - Catch That Cow
- HDOJ Catch That Cow
- 2717Catch That Cow
- POJ3278 Catch That Cow
- 3278Catch That Cow
- Catch That Cow(bfs)
- Catch that cow (H2717)
- POJ3278--Catch That Cow
- Catch That Cow
- Catch That Cow+BFS
- C++学习笔记:为什么不要重载逻辑与和逻辑或&& || 操作符
- python string unicode字符串
- svm小结
- android子线程handler获取数据
- Android存储子系统
- Catch That Cow
- Android AccessibilityService 使用详解
- java中判断字符串是否为数字的方法的几种方法
- UIPageController的使用
- React富交互性的动态用户界面
- OO实现ALV
- QT 控件和ID绑定 QObjectUserData
- iOS开发之 线程安全机制
- 排序算法总结