poj 3278 catch that cow BFS(基础水)

Catch That Cow
Time Limit: 2000MS Memory Limit: 65536K
Total Submissions: 61826 Accepted: 19329

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

5 17

Sample Output

4

Hint

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.

Source

USACO 2007 Open Silver

[Submit]   [Go Back]   [Status]   [Discuss]

Home Page   Go Back  To top

#include<stdio.h>
#include<string.h>
#include<queue>
#include<iostream>
#include<algorithm>
using namespace std;

转载于:https://www.cnblogs.com/13224ACMer/p/4738717.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/459016.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

制作已编译的html帮助文件

http://www.cnblogs.com/cm186man/archive/2008/03/10/1098896.html引用 HTML帮助文档从结构上来看可分为两个部分&#xff0c;运行器和文档内容。它的一个好处是能使帮助文档跨平台运行&#xff0c;只要有不同平台上的运行器和浏览器&#xff0c;帮助文档不再需要重新编制&…

matlab %3c handle,volume browser (updated).htm 源代码在线查看 - Matlab显式三维地震数据的源代码 资源下载 虫虫电子下载站...

Comments: any comments on this error:??? Error using > timesIntegers can only be combined with integers of the same class, or scalar doubles.Error in > interp3>linear at 368 F (( arg4(ndx).*(1-t) arg4(ndx1).*t ).*(1-s) ...Error in > inter…

PHPer转战Android的学习过程以及Android学习

原文作者&#xff1a; eoeadmin原文地址&#xff1a; http://my.eoe.cn/shuhai/archive/19684.html--------------------------------------------这篇文章主要写了一个PHP程序猿是如何转战学习Android的。 第一步&#xff1a;直接跨过java的学习&#xff0c;原因有我之前看过毕…

SQL中实现截取字符串的函数

SQL中实现截取字符串的函数 如果想实现从数据库中取数据时截取一个字段下的内容或者截取一串字符串&#xff0c;则能够实现这种效果的函数有Left&#xff0c;Right&#xff0c;SubString三个函数。1.Left函数&#xff1a;Left&#xff08;character_expression , integer_expre…

php时区设置问题,PHP 的时区设置问题_PHP教程

装上PHP5后你会发现这样的问题&#xff1a;你也许会发现&#xff0c;输出的时间和你现在的时间是不相同的。原因是假如你不在程序或配置文件中设置你的服务器当地时区的话&#xff0c;PHP所取的时间是格林威治标准时间&#xff0c;所以和你当地的时间会有出入。格林威治标准时间…

HDU 5392 BC #51

就是求最大公倍数&#xff0c;但要用分解质因子求。 自己写的WA到爆。。。。 #include<iostream> #include<stdio.h> #include<math.h>#include<algorithm>using namespace std;#define rd(x) scanf("%d",&x) #define rd2(x,y) scanf(&q…

下拉框——把一个select框中选中内容移到另一个select框中遇到的问题

在使用jQuery实现把一个select框中选中内容移到另一个select框中功能时遇到了一个问题&#xff0c;就是点击按钮时内容可以到另一个select框中&#xff0c;但是到了另一个select框中的内容却很快闪退回原来的select框中&#xff0c;代码如下&#xff1a; <select class"…

windows API 串口编程参考

*************************************************** 更多精彩&#xff0c;欢迎进入&#xff1a;http://shop115376623.taobao.com *************************************************** &#xff08;一&#xff09;Windows API串口通信编程概述 Windows环境下的串口编程与D…

jquery post php返回html,jquery ajax post 提交数据,返回的是当前网页的html?

代码如下用户名:密 码:$("#login_submit").bind("click",function(){var type "post";var url "index.php?madmin&cindex&acheckLogin";var formArrays $("#admin_form").serializeArray();var requestData …

[转]Android Studio系列教程六--Gradle多渠道打包

转自&#xff1a;http://www.stormzhang.com/devtools/2015/01/15/android-studio-tutorial6/ Android Studio系列教程六--Gradle多渠道打包 2015 年 01 月 15 日 devtools本文为个人原创&#xff0c;欢迎转载&#xff0c;但请务必在明显位置注明出处&#xff01; 由于国内Andr…

服务器上装filezilla server后,本地的ftp客户端连接不上去

公司一台服务器&#xff0c;上面装了filezilla server后&#xff0c;按平常配置好了&#xff0c;但是在本地用FTP客户端不管怎么连接都连接不上&#xff0c;本地FTP客户端总提示连接失败&#xff0c;远程filezilla server的界面也没有提示有人连接&#xff0c; 仔细看了一下&am…

数据结构与算法之堆与堆排序

在数据结构中&#xff0c;堆其实就是一棵完全二叉树。我们知道内存中也有一块叫做堆的存储区域&#xff0c;但是这与数据结构中的堆是完全不同的概念。在数据结构中&#xff0c;堆分为大根堆和小根堆&#xff0c;大根堆就是根结点的关键字大于等于任一个子节点的关键字&#xf…

非法操作 login.php,阅文游戏中心 h5游戏接入wiki

阅文游戏中心《h5游戏 CP接口规范》接口要求规范游戏方接口说明&#xff1a;游戏方需按照规范提供&#xff0c;阅文进行调用阅文接口说明&#xff1a;阅文提供&#xff0c;游戏方调用参数 time 为Unix 时间戳(January 1 1970 00:00:00 GMT 起的秒数) &#xff0c;单位为秒编码统…

串口通信与编程:串口基础知识

*************************************************** 更多精彩&#xff0c;欢迎进入&#xff1a;http://shop115376623.taobao.com *************************************************** 串口是串行接口&#xff08;serial port&#xff09;的简称&#xff0c;也称为串行通信…

jmeter上传文件搞了一天,才搞定,没高人帮忙效率就是低,赶紧记下来,以备后用...

jmeter上传文件搞了一天&#xff0c;才搞定&#xff0c;没高人帮忙效率就是低&#xff0c;赶紧记下来&#xff0c;以备后用 先用谷歌浏览器抓包&#xff0c;抓到的包类似这样&#xff1a; 在jmeter里添加一个http请求&#xff0c;配置好参数&#xff0c;方法&#xff0c;端口&a…

自定义dialog

2019独角兽企业重金招聘Python工程师标准>>> R.layout.layout_insert_dialog自定义布局 View mViewLayoutInflater.from(MainActivity.this).inflate(R.layout.layout_insert_dialog, null); AlertDialog.Builder dialognew AlertDialog.Builder (MainActivity.this…

js unescape 对应php的函数,php实现Javascript的escape和unescape函数

由于需要用到php调用js文件&#xff0c;在网上找了相关的资料&#xff0c;并改写了相关的方法。php实现 Javascript的escape函数方法&#xff1a;function escape($str) {preg_match_all("/[/xc2-/xdf][/x80-/xbf]|[/xe0-/xef][/x80-/xbf]{2}|[/xf0-/xff][/x80-/xbf]{3}|[…

字符数组,字符串、数字转化

<p style"margin-top: 5px; margin-bottom: 5px; padding-top: 0px; padding-bottom: 0px; line-height: 26px; word-wrap: break-word; color: rgb(102, 102, 102); font-family: 宋体, Arial; font-size: 16px;">//****************************************…

PE文件RV转FOA及FOA转RVA

/************************************************************************/ /* 功能:虚拟内存相对地址和文件偏移的转换 参数&#xff1a;stRVA&#xff1a; 虚拟内存相对偏移地址 lpFileBuf: 文件起始地址 返回&#xff1a;转换后的文件偏移地址 */ /*****************…

SurfaceView类透明背景设置

将SurfaceView背景设置为透明&#xff0c;主要添加以下几句话就可以了&#xff1a; 在SurfaceView创建后设置一下下面的参数&#xff1a; setZOrderOnTop(true); getHolder().setFormat(PixelFormat.TRANSLUCENT); 还有在draw方法中绘制背景颜色的时候以下面的方式进行绘制就可…