zoukankan      html  css  js  c++  java
  • ACM_闹钟人生(水题)

    闹钟人生

    Time Limit: 2000/1000ms (Java/Others)

    Problem Description:

    已知一个时钟一开始指向0点,顺时针走了n个小时,求它最终所指向的数字(时间按12进制计算)。

    Input:

    多组输入,每组一个n(-10^7<=n<=10^7)

    Output:

    输出指针所指数字

    Sample Input:

    4
    12
    15

    Sample Output:

    4
    0
    3
    解题思路:水题!!!取余。但是要注意的一点,负数取余任何一个不为0的数之后都是负数,又要求输出是12进制的,负数说明逆时针转,所以要将其调整成正数,再单一出口取余输出。水过。
     1 #include<bits/stdc++.h>
     2 using namespace std;
     3 int main()
     4 {
     5     int n;
     6     while(cin>>n){
     7         while(n<0)n+=12;
     8         cout<<(n%12)<<endl;
     9     }
    10     return 0;
    11 }
  • 相关阅读:
    模板
    2019牛客暑期多校训练营(第五场)
    Codeforces
    Codeforces
    SCUT
    模板
    Codeforces
    2019 Multi-University Training Contest 4
    Codeforces
    Codeforces
  • 原文地址:https://www.cnblogs.com/acgoto/p/8997895.html
Copyright © 2011-2022 走看看