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

建议使用的浏览器:

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

2304:Combination Lock

题目描述
Now that you're back to school for another term, you need to remember how to work the combination lock on your locker. A common design is that of the Master Brand, shown at right. The lock has a dial with 40 calibration marks numbered 0 to 39. A combination consists of 3 of these numbers; for example: 15-25-8. To open the lock, the following steps are taken:
  • turn the dial clockwise 2 full turns
  • stop at the first number of the combination
  • turn the dial counter-clockwise 1 full turn
  • continue turning counter-clockwise until the 2nd number is reached
  • turn the dial clockwise again until the 3rd number is reached
  • pull the shank and the lock will open.

Given the initial position of the dial and the combination for the lock, how many degrees is the dial rotated in total (clockwise plus counter-clockwise) in opening the lock?
输入解释
Input consists of several test cases. For each case there is a line of input containing 4 numbers between 0 and 39. The first number is the position of the dial. The next three numbers are the combination. Consecutive numbers in the combination will be distinct. A line containing 0 0 0 0 follows the last case.
输出解释
For each case, print a line with a single integer: the number of degrees that the dial must be turned to open the lock.
输入样例
0 30 0 30
5 35 5 35
0 20 0 20
7 27 7 27
0 10 0 10
9 19 9 19
0 0 0 0
输出样例
1350
1350
1620
1620
1890
1890

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

源链接: POJ-2304

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

共提交 0

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