zoukankan      html  css  js  c++  java
  • 解码锁

    Problem B: B

    Time Limit: 1 Sec  Memory Limit: 128 MB
    Submit: 96  Solved: 43
    [Submit][Status][Web Board]

    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
    对应的程序如下:
     
    #include"stdio.h"
    #include"stdlib.h"
    int main()
    {
       int a,b,c,d,sum;
       while(1)
       {
            scanf("%d%d%d%d",&a,&b,&c,&d);
            if((!a)&&(!b)&&(!c)&&(!d))
              break;
            else
             sum=720+360;
             sum+=((40-b+a)%40*9);
             sum+=((40-b+c)%40*9);
             sum+=((40-d+c)%40*9);
             printf("%d\n",sum);
       }
       // system("pause");
       return 0; 
           
    }
  • 相关阅读:
    iis 配置域名访问
    js将base64做UrlEncode转码
    vue-router 刷新当前路由
    iview default-file-list 动态赋值不显示
    vue2.0 axios 登录post请求自动读取Set-Cookie设置
    iis 使用主机名配置需注意
    【LeetCode.1】 求两数之和
    【Docker学习笔记】Docker常用命令学习
    【Docker学习笔记】Docker基本组成与安装
    微信小程序对接七牛云 上传多张图片、预览、删除 (测试可用)
  • 原文地址:https://www.cnblogs.com/QQbai/p/2122243.html
Copyright © 2011-2022 走看看