Problem A. Naughty fairies
Description
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.
Input
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.
Output
For each test case, you should output just a number K indicating the minimum time (in minutes) Lily needed to finish her illusion magic.
Sample Input
5 2
1 99
86 32
0 0
Sample Output
2
98
12
Problem B. Prison Break
Description
Rompire is a robot kingdom and a lot of robots live there peacefully. But one day, the king of Rompire was captured by human beings. His thinking circuit was changed by human and thus became a tyrant. All those who are against him were put into jail, including our clever Micheal#1. Now it’s time to escape, but Micheal#1 needs an optimal plan and he contacts you, one of his human friends, for help.
The jail area is a rectangle contains n×m little grids, each grid might be one of the following:
1) Empty area, represented by a capital letter ‘S’.
2) The starting position of Micheal#1, represented by a capital letter ‘F’.
3) Energy pool, represented by a capital letter ‘G’. When entering an e
ACM英文试题_工学_高等教育_教育专区。ACM International Collegiate Programming Contest Problem One: Jogging Trails Gord is training for aACM International ...
2009年acm竞赛试题[1]_IT/计算机_专业资料。竞赛题基隆商工校内 ACM_第 25 ...每个样本是由 1 个英文字再加上 9 个数字所组成的字符 串。 【输出文件格式...
百度文库 教育专区 外语学习 英语考试专题推荐 北师大二附理科学霸高中... 东北... ACM竞赛之输入输出 3页 1下载券 ACM竞赛试题集锦 3页 免费 ACM竞赛讲座之一...
ACM竞赛试题集锦_IT/计算机_专业资料。ACM竞赛试题集锦取石子游戏 Time Limit:1S Memory Limit:1000K Total Submit:505 Accepted:90 Description 有两堆石子,数量...
2010 年 5 月 16 日 所有的题目 时间限制: 1 秒 【试题一】 房间安排 ... 第三届河南省acm竞赛(正... 10页 免费 ACM竞赛试题(英文) 6页 免费 第...
ACM程序大赛选拔初赛试题 - 参考答案_其它考试_资格考试/认证_教育专区。很好...1、字母排序 难度系数:★☆☆☆ 题意:有 10 个英文字母(包含大小写),用计算机...
2009年acm竞赛试题_IT/计算机_专业资料。2009年acm竞赛试题,可以通过这些题的...应该很多人都知道,我们的身份证是由 1 个英文字,再加上 9 个数字所组成....
杭电acm题目水题英文题目、翻译及ac源代码_计算机软件及应用_IT/计算机_专业资料。如题。供无网人士享用。今日推荐 157份文档 2015国家公务员考试备战攻略...
此题虽为 ACM 比赛用题,却非常简单,没有什么特别之处,不牵扯数据结构, 实为初学者建立自信心的灵丹妙药。 英文原文 P1 - ACM SPPC 1 of 2 Saturday, 20/...
ACM竞赛讲座_IT/计算机_专业资料。ACM讲座? ACM大学生程序设计 竞赛浅谈 ACM/...竞赛 时,每队三人仅拥有一台计算机,在五个小时内,解答5~10道题目(题目是英文...
热门文档