本文共 1553 字,大约阅读时间需要 5 分钟。
Time Limit: 1000MS | | Memory Limit: 131072K |
Total Submissions: 7912 | | Accepted: 5024 |
Description
Our vicar raised money to have the church clock repaired for several weeks. The big clock, which used to strike the hours days and nights, was damaged several weeks ago and had been silent since then.
After the clock was repaired, it works all right, but there is still something wrong with it: the clock will strike thirteen times at one o’clock, fourteen times at two o’clock... 24 times at 12:00, 1 time at 13:00...
How many times will it strike now?
Input
The first line consists of only one integer T (T <= 30), representing the number of test cases. Then T cases follow.
Each test case consists of only one line, representing the time now. Each line includes 2 integers H, M separated by a symbol ":". (0 <= H < 24, 0 <= M < 60)
Output
For each test case, output the answer in one line.
Sample Input
31:0001:0100:00
Sample Output
13012
Source
一个钟坏了,0:00敲12下,1:00敲13下,2:00敲14下……11:00敲23下,12:00敲24下,13:00敲1下,14:00敲2下……。不是整点的时间不敲钟输出0.其他时间,输出对应敲击的次数。
除了12点以外,i点的时候敲击(12+i)%24下,非整点,敲击0下。
#include #include #include int main(void){ int ii, casenum; int h, m; scanf("%d", &casenum); for (ii = 0; ii < casenum; ii++){ scanf("%d:%d", &h, &m); if (m == 0){ if (h == 12){ printf("24\n"); } else{ printf("%d\n", (12 + h) % 24); } } else{ printf("0\n"); } } return 0;}
转载地址:http://kloji.baihongyu.com/