编程介的小学生 2017-08-17 13:03 采纳率: 20.5%
浏览 780
已采纳

Digital Clock

Digital clocks usually show the time in the form hh:mm:ss, where hh is a number between 00 and 23, and both mm and ss are numbers between 00 and 59. Removing the colons from hh:mm:ss will result in an integer hhmmss, which is called a clock integer. For example, the clock integer of 17:05:13 is 170513 and the clock integer of 00:07:37 is 737.

You are given a time interval and you are to determine the number of clock integers in it that are multiples of 3. A time interval will be given by specifying its start and end time. For example, the time interval [00:59:58, 01:01:24] has a total of 1+1+60+25=87 clock integers, namely, 5958, 5959, 10000 through 10059, and 10100 through 10124. How many of them are multiples of 3?

Note that a time interval that includes midnight may have a start time greater than its end time, as in [22:47:03, 01:03:24]. You may assume that a time interval is at least one second long and shorter than 24 hours.

Write a program that can determine the number of multiples of 3 in a time interval.

Input

Your program is to read from standard input. The input consists of T test cases. The number of test cases T is given in the first line of the input. Each test case consists of a single line that contains the start time and end time of a time interval, which are separated by a single space.

Output

Your program is to write to standard output. Each test case outputs exactly one line. Print the number of multiples of 3 among the clock integers in the time interval. The following shows a sample input with three test cases and its output.

Sample Input

3
00:59:58 01:01:24
22:47:03 01:03:24
00:00:09 00:03:37
Sample Output

29
2727
70

  • 写回答

1条回答 默认 最新

报告相同问题?

悬赏问题

  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么