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 ...
随机推荐
- Android开发之计算器(一)界面设计之activity_main布局文件
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=&quo ...
- Redis源码研究--redis.h
------------7月3日------------ /* The redisOp structure defines a Redis Operation, that is an instance ...
- rinetd 安装使用
1 下载解压: wget http://www.boutell.com/rinetd/http/rinetd.tar.gz tar zxvf rinetd.tar.gz 2 手动建立目录 mkdir ...
- opencv学习笔记(04)——ROI
ROI的用法:1.直接相加:2.掩码法 #include <opencv2\highgui\highgui.hpp> #include <opencv2\imgproc\imgpro ...
- WPF-控件-将ListBox条目水平排列
<Grid Margin="6"> <ListBox> <!--ItemsPanel--> <ListBox.ItemsPanel> ...
- c语言调试开关
上一篇转载的没看懂,参考别人的代码,自己又琢磨了一个调试技巧,挺好用,姑且就叫调试开关吧,欢迎指正!!! /*功能:调试开关 *描述:if条件成立,则打印调试信息,否则不打印() * */ #incl ...
- iOS多线程编程Part 2/3 - NSOperation
多线程编程Part 1介绍了NSThread以及NSRunLoop,这篇Blog介绍另一种并发编程技术:NSOPeration. NSOperation & NSOperationQueue ...
- [转]如何利用ndk-stack工具查看so库的调用堆栈【代码示例】?
如何利用ndk-stack工具查看so库的调用堆栈[代码示例]? http://hi.baidu.com/subo4110/item/d00395b3bf63e4432bebe36d Step1:An ...
- NOIP2015 心得
NOIP2015的复赛已经过去一个多星期了,成绩也已经出来了,作为一个大(ruo)山(sheng)东的蒟蒻,在学了一年之后拿到了255的成绩.这个成绩并不是很好,但也算在我的预料之内. 第一天第一题水 ...
- UML 小结(5)- 图解 Rational Rose 的详细安装过程
在学习UML的时候,会用到画图工具:Rotional Rose . 原以为这款软件直接下载下来或者跟朋友那边拷过来就可以直接用了,结果却是没有那么简单,如果读者您也是为了解决这个家伙的安装问题的话,那 ...