22365_CombinationLock

2022-5-16 18:21| 发布者: Hocassian| 查看: 27| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-5-89506359634200-Problem List-采集的数据-后羿采集器.html

Pro.ID

22365

Title

Combination Lock

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=22365

AC

19

Submit

35

Ratio

54.29%

时间&空间限制

  • Time Limit: 200/100 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others)
  • 描述

    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.

    输出

    Description

    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

    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.

    Output

    For each case, print a line with a single integer: the number of degrees that the dial must be turned to open the lock.

    Sample Input

    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

    Sample Output

    1350
    1350
    1620
    1620
    1890
    1890

    Source

    样例输入

    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

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部