当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

3278:Catch That Cow

题目描述

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?

输入解释
Line 1: Two space-separated integers: N and K
输出解释
Line 1: The least amount of time, in minutes, it takes for Farmer John to catch the fugitive cow.
输入样例
5 17
输出样例
4
提示
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.

该题目是Virtual Judge题目,来自 北京大学POJ

题目来源 USACO 2007 Open Silver

源链接: POJ-3278

最后修改于 2020-10-29T06:57:35+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000 65536