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

poj 3278 catch that cow BFS(基础水)相关推荐

  1. POJ 3278 Catch That Cow BFS

    Catch That Cow Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 32071   Accepted: 9866 D ...

  2. BFS POJ 3278 Catch That Cow

    题目传送门 1 /* 2 BFS简单题:考虑x-1,x+1,x*2三种情况,bfs队列练练手 3 */ 4 #include <cstdio> 5 #include <iostrea ...

  3. POJ 3278 Catch That Cow

    Catch That Cow Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 30924   Accepted: 9536 D ...

  4. POJ 3278 Catch That Cow(BFS)

    题目网址:http://poj.org/problem?id=3278 题目: Catch That Cow Time Limit: 2000MS   Memory Limit: 65536K Tot ...

  5. bfs+dfs分析----poj 3278 Catch That Cow

    题目详情 Catch That Cow Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 115430   Accepted:  ...

  6. POJ 3287 Catch That Cow(bfs)

          看懂意思就很简单了,给你一个数,每次只能加一或者减一或者乘2,问最少几次才能变成另一个数,就是一个简单的bfs过程,看代码吧. AC代码: #include <iostream> ...

  7. poj 3278 Catch That Cow(广搜)

    Catch That Cow Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 45087   Accepted: 14116 ...

  8. POJ 3278 Catch That Cow

    Catch That Cow Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 35043   Accepted: 10800 ...

  9. poj 3278 Catch That Cow 广搜

    hdu 2717 Catch That Cow,题目链接 Time Limit: 5000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Jav ...

最新文章

  1. element表格取消全选_ElementUi 表格取消全选框,用文字表示
  2. 什么是分镜头剧本?(分镜头剧本是将文字转换成立体视听形象的中间媒介。主要任务是根据解说词和电视文学脚本来设计相应画面,配置音乐音响,把握片子的节奏和风格等。)
  3. 【转】使 用免费UMS架设Flash流媒体服务
  4. Spring Boot WebMagic 入库时 mapper注入提示空指针,以及正确的操作
  5. java 简单的计算器程序,Java 简易计算器程序
  6. pyflink shell的remote模式下的实验记录
  7. php获取服务器名称,PHP 获取服务器详细信息
  8. OpenTelemetry - 云原生下可观测性的新标准
  9. jquery validate 中文教程【入门到精通】
  10. 小学生计算机课堂实践的重要性,小学《信息技术》有效课堂教学的实践与研究课题方案...
  11. AES-128\192\256加密算法及其安全脆弱分析
  12. Maven 中 com.adobe.blazeds 的配置失效解决方案
  13. 华为 IPD 集成产品开发流程的缺点和适用局限性
  14. 支持傲腾技术的服务器主板,G4560可以用傲腾内存么
  15. 3des解密 mysql_转角处拐弯007
  16. 希望各位dalao不吝赐教
  17. JAVA运行内存的设置
  18. 对象的属性名和属性值
  19. 基于Protobuf的通讯库--Poppy简介
  20. sqlserver 中使用sqlcmd 执行*.sql文件

热门文章

  1. 【 HDU - 1525 】Euclid's Game(较难找规律,玄学博弈,分析必败点必胜点)
  2. java读取yaml配置文件,snakeyaml读取yaml配置文件
  3. c语言编写一个函数判断闰年,C语言:实现一个函数判断year是不是闰年
  4. MySQL命令(二)| 表的增删查改、聚合函数(复合函数)、联合查询
  5. 《Head First设计模式》第三章笔记 装饰者模式
  6. C++:28 --- C++内存布局(上)
  7. ubuntu apache配置负载均衡篇(一)
  8. 《Python Cookbook 3rd》笔记(2.18):字符串令牌解析
  9. android安全 报告,Android安全检测报告
  10. java图形用户登录界面_Java简单登录图形界面