POJ 3278 Catch That Cow
来源:互联网 发布:午夜美女直播软件 编辑:程序博客网 时间:2024/05/19 12:37
#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>#include<queue>const int maxn=200000+10;int f[maxn],vis[maxn];using namespace std;int main(){ memset(f,0,sizeof(f)); int n,k,ans,i,j,h; scanf("%d%d",&n,&k); queue<int> q; while(!q.empty()) q.pop(); q.push(n); while(!q.empty()) { ans=q.front(); if(ans==k) {printf("%d\n",f[ans]);break;} i=ans-1; if(!vis[i]&&i>=0&&i<=100000){ vis[i]=1; f[i]=f[ans]+1; q.push(i);} j=ans+1; if(!vis[j]&&j>=0&&j<=100000){ vis[j]=1; f[j]=f[ans]+1; q.push(j);} h=ans*2; if(!vis[h]&&h>=0&&h<=100000){ vis[h]=1; f[h]=f[ans]+1; q.push(h);} q.pop(); } return 0;}
0 0
- poj 3278 Catch That Cow
- POJ 3278 Catch That Cow
- poj 3278 catch that cow
- poj 3278 Catch That Cow
- POJ 3278 Catch That Cow
- Poj 3278 Catch That Cow
- POJ 3278 Catch That Cow
- POJ 3278 Catch That Cow
- POJ 3278 Catch That Cow
- poj 3278 Catch That Cow
- POJ 3278 Catch That Cow
- poj 3278 Catch That Cow
- poj 3278 Catch That Cow
- POJ 3278 Catch That Cow
- POJ 3278 - Catch That Cow
- POJ 3278 Catch That Cow
- POJ 3278 Catch That Cow
- POJ-3278-Catch That Cow
- virtualbox下ubuntu访问主机共享文件夹
- SpringMVC接收复杂集合参数
- 类构造函数初始值列表
- String,StringBuffer与StringBuilder的区别??
- 一个关于NetworkComms.Net的入门教程官方视频
- POJ 3278 Catch That Cow
- hdu Ignatius and the Princess I
- python range()和arange()
- java中stringBuilder的用法
- CSS中不为人知Zoom属性的使用介绍(IE私有属性)
- 2016 多校 hdu 5723
- 有关于Ajax的参数传递在MVC当中的应用
- HDU 5724 (博弈)
- return continue break