`
joe_zxy
  • 浏览: 43458 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
最近访客 更多访客>>
社区版块
存档分类
最新评论

POJ ACM习题【No.2840】

    博客分类:
  • ACM
 
阅读更多
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);
			}
		}
	}

}
 
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics