您的位置:首页 > 其它

POJ 2840 Big Clock(我的水题之路——水,钟)

2012-02-12 17:39 323 查看
Big Clock

Time Limit: 1000MSMemory Limit: 131072K
Total Submissions: 7912Accepted: 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
3
1:00
01:01
00:00


Sample Output
13
0
12


Source

POJ Monthly--2006.06.25, Lei Tao

一个钟坏了,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下。

代码(1AC):

#include <cstdio>
#include <cstdlib>
#include <cstring>

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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: