BZOJ 1646: [Usaco2007 Open]Catch That Cow 抓住那只牛( BFS )
BFS...
--------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------
1646: [Usaco2007 Open]Catch That Cow 抓住那只牛
Time Limit: 5 Sec Memory Limit: 64 MB
Submit: 764 Solved: 361
[Submit][Status][Discuss]
Description
Farmer John has been informed of the location of a fugitive cow and wants to catch her immediately. He starts at a point N (0 <= N <= 100,000) on a number line and the cow is at a point K (0 <= K <= 100,000) on the same number line. Farmer John has two modes of transportation: walking and teleporting. * Walking: FJ can move from any point X to the points X-1 or X+1 in a single minute * Teleporting: FJ can move from any point X to the point 2*X in a single minute. If the cow, unaware of its pursuit, does not move at all, how long does it take for Farmer John to retrieve it?
Input
* Line 1: Two space-separated integers: N and K
Output
* Line 1: The least amount of time, in minutes, it takes for Farmer John to catch the fugitive cow.
Sample Input
Farmer John starts at point 5 and the fugitive cow is at point 17.
Sample Output
OUTPUT DETAILS:
The fastest way for Farmer John to reach the fugitive cow is to
move along the following path: 5-10-9-18-17, which takes 4 minutes.
HINT
Source
BZOJ 1646: [Usaco2007 Open]Catch That Cow 抓住那只牛( BFS )的更多相关文章
- bzoj 1646: [Usaco2007 Open]Catch That Cow 抓住那只牛【bfs】
满脑子dp简直魔性 模拟题意bfs转移即可 #include<iostream> #include<cstdio> #include<queue> using na ...
- 【BZOJ】1646: [Usaco2007 Open]Catch That Cow 抓住那只牛(bfs)
http://www.lydsy.com/JudgeOnline/problem.php?id=1646 这一题开始想到的是dfs啊,,但是本机测样例都已经re了... 那么考虑bfs...很巧妙? ...
- BZOJ1646: [Usaco2007 Open]Catch That Cow 抓住那只牛
1646: [Usaco2007 Open]Catch That Cow 抓住那只牛 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 634 Solved ...
- 2014.6.14模拟赛【bzoj1646】[Usaco2007 Open]Catch That Cow 抓住那只牛
Description Farmer John has been informed of the location of a fugitive cow and wants to catch her i ...
- 【题解】[Usaco2007 Open]Catch That Cow 抓住那只牛-C++
题目DescriptionFarmer John has been informed of the location of a fugitive cow and wants to catch her ...
- 抓住那只牛!Catch That Cow POJ-3278 BFS
题目链接:Catch That Cow 题目大意 FJ丢了一头牛,FJ在数轴上位置为n的点,牛在数轴上位置为k的点.FJ一分钟能进行以下三种操作:前进一个单位,后退一个单位,或者传送到坐标为当前位置两 ...
- hdu 2717 Catch That Cow(广搜bfs)
题目链接:http://i.cnblogs.com/EditPosts.aspx?opt=1 Catch That Cow Time Limit: 5000/2000 MS (Java/Others) ...
- 【OpenJ_Bailian - 4001】 Catch That Cow(bfs+优先队列)
Catch That Cow Descriptions: Farmer John has been informed of the location of a fugitive cow and wan ...
- POJ 3278 Catch That Cow(bfs)
传送门 Catch That Cow Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 80273 Accepted: 25 ...
随机推荐
- Java中的枚举类型详解
枚举类型介绍 枚举类型(Enumerated Type) 很早就出现在编程语言中,它被用来将一组类似的值包含到一种类型当中.而这种枚举类型的名称则会被定义成独一无二的类型描述符,在这一点上和常量的定义 ...
- 三种尺寸:手机SIM卡使用指南
毫无疑问目前卖的最火的手机非iPhone 5s莫属,相信仍有不少网友目前处于观望之中,由于iPhone 5s和iPhone 5c采用与iPhone相同的Nano-SIM卡,因此不少新用户在使用之前也徒 ...
- perl 爬取上市公司业绩预告
<pre name="code" class="python">use LWP::UserAgent; use utf8; use DBI; use ...
- PHP下通过file_get_contents\curl的方法实现获取远程网页内容(别忘了还有PhpRPC)
[php]PHP中file_get_contents()与file_put_contents()函数细节详解 php函数file_get_contents(一) 案例: 早在2010年时候遇到过这样的 ...
- c语言中-----分配内存函数
原型: void * realloc(void *p, size_t size); realloc 可以对给定的指针所指的空间进行扩大 或者 缩小, 原有内存的数据保持不变.当然,对于缩小,则缩小部 ...
- 获取当前WEB应用全路径
<%String path = request.getContextPath();String basePath =request.getScheme()+"://"+req ...
- 驱动之路四------adc驱动(input设备)
开发板:smdk6410 开发环境:Linux 突然想起一点,写这些驱动,内核需要配成支持抢占才行. 前面的博客已经将其它的基本知识都解释了,这里也就不过多的阐述了,咱就直接写代码吧 这次写的是adc ...
- ThinkPHP第十四天(显示TRACE界面配置,关联模型详解定义)
1.显示TRACE界面,首选需要在显示模版界面,$this->display(),然后需要在配置文件中配置 SHOW_PAGE_TRACE => true 2.关联模型使用 主表以user ...
- lambda, reduce, map求阶乘之和
学完这几个优雅的内建函数,就可以做一些有趣的小练习来激发兴趣了.而python最大的好处便是简洁,看下边要求 用1行代码求 1! + 2! + 3! + ... + 10! 求阶乘 reduce函数用 ...
- sql语句分析
show profile是由Jeremy Cole捐献给MySQL社区版本的.默认的是关闭的,但是会话级别可以开启这个功能.开启它可以让MySQL收集在执行语句的时候所使用的资源.为了统计报表,把pr ...