zoukankan      html  css  js  c++  java
  • Measuring Lengths in Baden

    Description
    Measuring Lengths in Baden
    time limit per test: 2 seconds
    memory limit per test: 256 megabytes
    input: standard input
    output: standard output

    Lengths are measures in Baden in inches and feet. To a length from centimeters it is enough to know that an inch equals three centimeters in Baden and one foot contains 12 inches.

    You are given a length equal to n centimeters. Your task is to convert it to feet and inches so that the number of feet was maximum. The result should be an integer rounded to the closest value containing an integral number of inches.

    Note that when you round up, 1 cm rounds up to 0 inches and 2 cm round up to 1 inch.

    Input

    The only line contains an integer n (1 ≤ n ≤ 10000).

    Output

    Print two non-negative space-separated integers a and b, where a is the numbers of feet and b is the number of inches.

    Sample test(s)

    input
    42
    output
    1 2
    input
    5
    output
    0 2

     

     

     

     

     

     

    题解:输入厘米 转换为英尺英寸 注意四舍五入,"得寸进尺"。

    代码:

     1 #include <stdio.h>
     2 #include <stdlib.h>
     3 
     4 int main()
     5 {
     6     int n, a, b;
     7     scanf("%d", &n);
     8     a = n/36;
     9     b = (n-36*a)/3;
    10     if(n-36*a-3*b == 2) {
    11         b++;
    12         if(b==12) {
    13             a++;
    14             b = 0;
    15         }
    16     }
    17     printf("%d %d", a, b);
    18     return 0;
    19 }

    Problem - 125A - Codeforces

  • 相关阅读:
    司马光 王安石
    辛弃疾
    伯仲叔季
    三国时代
    西汉 东汉 三国(曹魏 蜀汉 东吴)
    数量关系练习题
    为什么不推荐使用外键约束
    Google Map API申请
    Android传感器——加速度传感器
    第三届空间信息智能服务研讨会
  • 原文地址:https://www.cnblogs.com/michaelwong/p/4116448.html
Copyright © 2011-2022 走看看