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 ...
随机推荐
- 《LDAP服务器和客户端的加密认证》RHEL6——第二篇 运维工程师必考
服务端的配置: (基于原先配好的ldap服务器)打开加密认证: Iptables –F setenforce 0 1.编辑ldap的配置文件:slapd.conf 2.启动ldap服务器: 3.切换 ...
- 模拟抛硬币(C语言实现)
实现代码: #include<stdio.h> #include<stdlib.h> int heads() { ; } int main(int argc, char *ar ...
- js实现模拟自动点击按钮,并且在10秒倒计时之后疯狂点击
需求来自于csdn问答,可以利用这个原理做秒杀抢单外挂. 代码示例如下: <html> <head> <meta charset="utf-8"/&g ...
- UE4 将本地图片转成UTexture2D 在runtime显示
UFUNCTION(BlueprintCallable, Category = "TextureFromDisk") static class UTexture2D* GetTex ...
- mysql怎么从1开始递增
前提:使用SQLyog数据库管理工具 1.打开更改表: 2.点击表字段下方“高级属性”: 3.找到“自动递增”这一项,值改为1: 4.点击“确定”关闭高级属性表弹出框: 5.点击“Alter”关闭更改 ...
- PHP版本中的VC6,VC9,VC11,TS,NTS区别
以windows为例,看看下载到得php zip的文件名 php-5.4.4-nts-Win32-VC9-x86.zip VC6:legacy Visual Studio 6 compiler,是使用 ...
- 防火墙设置:虚拟机ping不通主机,但是主机可以ping通虚拟机(转载)
我在Windows7系统安装了虚拟机,通过虚拟机安装了Ubuntu13.04,我设置的主机与虚拟机的连接方式是桥接,安装好后,发现虚拟机ping不通主机,但是主机可以ping通虚拟机. 我的操作是:关 ...
- 强大的网络通信框架(不实现缓存)--第三方开源--AsyncHttpClient
AsyncHttpClient是一款比较流行的Android异步网路加载库,在github上的网址是:https://github.com/loopj/android-async-http但是Asyn ...
- Linq to Entities
首先要添加一个ADO.NET实体数据模型 添加一个Entities 对象,其用法和linqtosql类似例如: StudentInfoEntities2 entity = new StudentInf ...
- openerp - asterisk connector(转载)
原文:http://www.akretion.com/open-source-contributions/openerp-asterisk-voip-connector OpenERP - Aster ...