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

建议使用的浏览器:

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

3680:Naughty fairies

题目描述
Once upon a time, there lived a kind of fairy in the world. Those fairies could hear the voice of fruit trees, and helped people with a harvest. But people didn’t know that fruits are also those fairies’ favorite food. After the fairies ate people’s fruits, they always did something to cover it up.

One day a little fairy named Lily flew into an orchard and found a large peach tree. Hungry as Lily was, she started eating without thinking until her stomach was full. In the fairy world, when a fairy ate the fruits in a fruit tree, sometimes the fruit tree would feel honored and bore more fruits immediately. That’s why sometimes the number of fruits in a tree got increased after a fairy ate fruits of that tree.

But the fairies didn’t want people to find out weird things such as fruits become more or less suddenly. Lily decided to use a magic spell so that the orchard owner couldn’t find the change of the number of peaches.

Suppose there were N peaches on a tree originally and there were M peaches left after Lily was full. M may be greater than, less than or equal to N. All M peaches were visible at first, and Lily wanted to make an illusion so that exactly N peaches are visible.

Lily can do 3 kinds of spell to change the total visible number of peaches:

1) “PAPADOLA”:This spell would increase the number of visible peaches by one.
2) “EXPETO POTRONUM”:This spell would double the number of visible peaches.
3) “SAVIDA LOHA”:This spell would decrease the number of visible peaches by one.

Each spell would take one minute and Lily wanted to finish as fast as possible. Now please tell Lily the least time she needs to change the number of visible peaches to N.
输入解释
There are several test cases, ended by “0 0”.
For each test case, there are only one line containing two numbers separated by a blank, N and M, the original numbers of peaches and the numbers of peaches left(0<N,M<10500).There is no leading zero.
输出解释
For each test case, you should output just a number K indicating the minimum time (in minutes) Lily needed to finish her illusion magic.
输入样例
5 2
1 99
86 32
0 0
输出样例
2
98
12
来自杭电HDUOJ的附加信息
Recommend lcy&zhengfeng

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-3680

最后修改于 2020-10-25T23:05:54+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/1000MS(Java/Others) 32768/32768K(Java/Others)