POJ 2840 Big Clock(我的水题之路——水,钟)
2012-02-12 17:39
323 查看
Big Clock
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
Sample Output
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):
Time Limit: 1000MS | Memory Limit: 131072K | |
Total Submissions: 7912 | Accepted: 5024 |
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; }
相关文章推荐
- POJ 2840 Big Clock(水题)
- POJ 2840 Big Clock G++
- POJ 1656 Counting Black(我的水题之路——表格涂色)
- POJ 2013 Symmetric Order(我的水题之路——奇偶输出)
- POJ 2019 Cornfields(我的水题之路——多case??TLE??)
- POJ 2924 Gauß in Elementary School(我的水题之路——n到m的连和)
- POJ 3427 Ecology tax(我的水题之路——不同的理解,不同的AC)
- Poj 2840 Big Clock
- POJ 1207 The 3n+1 problem(我的水题之路——输入输出要保持原有顺序)
- POJ 1326 Mileage Bank(我的水题之路——模拟,四舍五入)
- POJ 1658 Eva's Problem(我的水题之路——等差or等比)
- POJ 2608 Soundex(我的水题之路——字符值)
- POJ 3006 Dirichlet's Theorem on Arithmetic Progressions(我的水题之路——加i个d后的第几个素数)
- POJ 3438 Look and Say(我的水题之路——N个M的队列)
- POJ 1046 Color Me Less(我的水题之路——坐标最小点)
- POJ 1247 Magnificent Meatballs(我的水题之路——数组两边求和)
- POJ 2028 When Can We Meet?(我的水题之路——边输入,边搜索)
- poj 2840 Big Clock
- POJ 2390 Bank Interest(我的水题之路——double和floa计算差别)
- POJ 2538 WERTYU(我的水题之路——键盘错位)