hdu2717 Catch That Cow
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的更多相关文章
- HDU2717 Catch That Cow 【广搜】
Catch That Cow Time Limit: 5000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) T ...
- POJ 3278 Catch That Cow(bfs)
传送门 Catch That Cow Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 80273 Accepted: 25 ...
- poj3278 Catch That Cow
Catch That Cow Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 73973 Accepted: 23308 ...
- catch that cow (bfs 搜索的实际应用,和图的邻接表的bfs遍历基本上一样)
Catch That Cow Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 38263 Accepted: 11891 ...
- poj 3278:Catch That Cow(简单一维广搜)
Catch That Cow Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 45648 Accepted: 14310 ...
- 2016HUAS暑假集训训练题 B - Catch That Cow
B - Catch That Cow Description Farmer John has been informed of the location of a fugitive cow and w ...
- 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 ...
- BFS POJ 3278 Catch That Cow
题目传送门 /* BFS简单题:考虑x-1,x+1,x*2三种情况,bfs队列练练手 */ #include <cstdio> #include <iostream> #inc ...
- 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 ...
随机推荐
- 《samba搭建win客户端和linux客户端的区别》
samba服务的搭建 客户的使用系统的不同也导致测试结果的不同. linux系统客户端: security = user or share smbclient -L //192.168.7.113/w ...
- 转: js操作cookie
cookie的几个概念 http://dearhappyfish.blog.163.com/blog/static/1901094152012422114753777/ js操作cookie 转:ht ...
- 【转】Class.forName()用法详解
ref: http://blog.csdn.net/kaiwii/article/details/7405761 主要功能 Class.forName(xxx.xx.xx)返回的是一个类 Class. ...
- Ubuntu下PHP开发配置(新增redis、sphinx、sqlserver相关配置)
由于本人比较懒,所以一般都是用xampp的直接拿来改的…………(当然xampp中一般php版本都是比较新的用的过程中请大家注意哈,可能会和老版本冲突) 此次除了使用xampp外,还扩展了sphinx, ...
- 【zendstudio】如何利用zendstudio新建 或导入php项目
一.利用ZendStudio创建 PHP Project 1. 打开ZendStudio, 选择:File à New à PHP Project, 如下图所示: 于是弹出如下界面: 在”Projec ...
- 使用android.support.design.widget.TabLayout出现java.lang.reflect.InvocationTargetException
解决方法: 1.在res里面的Values里面的styles定制一个自己的colorPrimary <style name="MyAppTheme" parent=" ...
- javascript中的省市级联效果
学习javascript的时候都遇到过这样的需求,不仅是省市,还有其他的一些场景,看看关键的代码有哪些吧. <head runat="server"> <titl ...
- Png图片的透明部分穿透测试
private void Window_MouseMove(object sender, MouseEventArgs e){ NavBtnList.Clear(); Point mou ...
- db2查看表空间
select substr(tbsp_name,1,20) as 表空间名称,substr(tbsp_content_type,1,10) as 表空间类型,sum(tbsp_total_size_k ...
- 【js】随机数
<script> function GetRandomNum(Min,Max){ var Range = Max - Min; var Rand = Math.random() ...