POJ ACM习题【No.2840】

Big Clock
Time Limit: 1000MS Memory Limit: 131072K
Total Submissions: 4320 Accepted: 2754

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

 

水题一道

 

import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		
		int num = Integer.valueOf(cin.nextLine()).intValue();
		for(int i = 0; i < num; i++)
		{
			String[] str = cin.nextLine().split(":");
			int hour = Integer.valueOf(str[0]).intValue();
			int minute = Integer.valueOf(str[1]).intValue();
			
			if(minute != 0)
				System.out.println("0");
			else
			{
				if(hour >= 0 && hour <= 12)
					System.out.println(hour+12);
				else
					System.out.println(hour-12);
			}
		}
	}

}
 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值