http://acm.hdu.edu.cn/showproblem.php?pid=2717

//水搜。。。

 #include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<iostream>
#include<queue>
using namespace std;
struct stu{
int x;
int t;
}abc,q;
int n,k;
int vis[];
void bfs()
{
queue<struct stu>p;
p.push(abc);
while(!p.empty())
{
abc=p.front();
p.pop();
if(abc.x==k)
{
printf("%d\n",abc.t);
return ;
}
q.x=abc.x-;
if(q.x>=&&q.x<=&&!vis[q.x])
{
q.t=abc.t+;
vis[q.x]=;
p.push(q);
}
q.x=abc.x+;
if(q.x>=&&q.x<=&&!vis[q.x])
{
q.t=abc.t+;
vis[q.x]=;
p.push(q);
}
q.x=abc.x*;
if(q.x>=&&q.x<=&&!vis[q.x])
{
q.t=abc.t+;
vis[q.x]=;
p.push(q);
}
}
} int main()
{
//freopen("in.txt","r",stdin);
while(~scanf("%d%d",&n,&k))
{
memset(vis,,sizeof(vis));
abc.x=n;
abc.t=;
vis[n]=;
bfs();
}
return ;
}

hdu2717 Catch That Cow的更多相关文章

  1. HDU2717 Catch That Cow 【广搜】

    Catch That Cow Time Limit: 5000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) T ...

  2. POJ 3278 Catch That Cow(bfs)

    传送门 Catch That Cow Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 80273   Accepted: 25 ...

  3. poj3278 Catch That Cow

    Catch That Cow Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 73973   Accepted: 23308 ...

  4. catch that cow (bfs 搜索的实际应用,和图的邻接表的bfs遍历基本上一样)

    Catch That Cow Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 38263   Accepted: 11891 ...

  5. poj 3278:Catch That Cow(简单一维广搜)

    Catch That Cow Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 45648   Accepted: 14310 ...

  6. 2016HUAS暑假集训训练题 B - Catch That Cow

    B - Catch That Cow Description Farmer John has been informed of the location of a fugitive cow and w ...

  7. HDU 2717 Catch That Cow (bfs)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2717 Catch That Cow Time Limit: 5000/2000 MS (Java/Ot ...

  8. BFS POJ 3278 Catch That Cow

    题目传送门 /* BFS简单题:考虑x-1,x+1,x*2三种情况,bfs队列练练手 */ #include <cstdio> #include <iostream> #inc ...

  9. Catch That Cow 分类: POJ 2015-06-29 19:06 10人阅读 评论(0) 收藏

    Catch That Cow Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 58072   Accepted: 18061 ...

随机推荐

  1. js 求前n项的 fibnaci 数列和

    function f(n) { var num1 = 1, num2 = 1; if (n == 1) document.write(num1);//n=1,输出1 else if (n > 1 ...

  2. memory model

    最近看C++11 atomic发现对memory_order很是不理解,memory_order_relaxed/memory_order_consume/memory_order_acquire/m ...

  3. linux传送文件至服务器

    scp安全文件拷贝(基于ssh的登陆)     1.你想把本地/home下的文件linux.tar.gz传送至远端服务器10.108.125.30,远端服务器的账号名为name,保存至服务器/home ...

  4. OpenDaylight之openflowjava的编译

    最近因为工作需要开始研究opendaylight,首先需要的是编译项目. 因为项目代码都是在git.opendaylight.org上的,所以需要先安装git工具. 另因为opendaylight项目 ...

  5. 打造简单实用的Thinkphp分页样式(Bootstrap版本)

    先吐槽一下ThinkPHP3.1版的分页样式,虽然看起来也很简单大方,但是所有的页码全是使用简单的数字,之间的空隙比较小,不大容易点,还有那个“前5页”和“后5页”显得有点多余,因为点击当前显示第一页 ...

  6. NaN属性,isNaN函数

    NaN:Not a Number,顾名思义,表示不是一个数字. 可以把 Number 对象设置为该值,来指示其不是数字值. 使用 isNaN() 全局函数来判断一个值是否是 NaN 值 详见 Java ...

  7. silverlight 文本框只能输入汉字

    private void txtName_KeyDown(object sender, KeyEventArgs e) { Regex rg = new Regex("^[\u4e00-\u ...

  8. 用Python作GIS之三:入口程序 - stargui.py

    """gui start file for Space-Time Analysis of Regional Systems#STARS的图形用户界面入口(高级用户可以直接 ...

  9. creating indexing for SQL tunning

    1. Not so long time ago, I got a report from customer. It's reported that they had a report getted v ...

  10. Team Homework #2

    王宇杰,北航计算机学院2011级本科生,学号11061180.本人没有什么特长,典型的死宅一个.学过一点c和java.对于第一次的个人作业就表示亚历山大,希望各位大神不吝分享自己的代码,并做好注释.希 ...