QOJ.ac

QOJ

时间限制: 10 s 内存限制: 256 MB 总分: 100

#11394. 时钟指针

统计

我们有一个模拟时钟,其三根指针(秒针、分针和时针)平滑地旋转。你可以测量秒针与另外两根指针之间的两个夹角。

编写一个程序,求出在给定时间或之后,第一次满足“没有两根指针重合”且“秒针与另外两根指针之间的两个夹角相等”的时间。

图 D.1. 秒针与另外两根指针之间的夹角

时钟并不局限于 12 小时制。$H$ 小时制时钟的时针每 $H$ 小时转一圈。分针每小时转一圈,秒针每分钟转一圈。在 0:0:0(午夜),所有指针都处于垂直向上位置。

输入格式

输入包含多个数据集。每个数据集包含一行,由四个整数 $H, h, m, s$ 组成,中间用空格分隔。$H$ 表示该时钟为 $H$ 小时制。$h, m, s$ 分别表示指定时间的时、分、秒。

你可以假设 $2 \le H \le 100$,$0 \le h < H$,$0 \le m < 60$ 且 $0 \le s < 60$。

输入的结束由一行包含四个零表示。

图 D.2. $H$ 小时制时钟示例(6 小时制和 15 小时制)

输出格式

输出在指定时间及之后,第一次满足“没有两根指针重合”且“秒针与另外两根指针之间的两个夹角相等”的时间 $T$。

对于时间 $T = h_o:m_o:s_o$(即 $h_o$ 点 $m_o$ 分 $s_o$ 秒),输出四个非负整数 $h_o, m_o, n, d$,中间用空格分隔,其中 $n/d$ 是表示 $s_o$ 的不可约分数。对于包括 0 在内的整数 $s_o$,令 $d$ 为 1。

时间应以 $H$ 小时的余数表示。换句话说,$(H-1):59:59$ 的一秒后是 $0:0:0$,而不是 $H:0:0$。

样例

样例输入 1

12 0 0 0
12 11 59 59
12 1 56 0
12 1 56 3
12 1 56 34
12 3 9 43
12 3 10 14
12 7 17 58
12 7 18 28
12 7 23 0
12 7 23 31
2 0 38 29
2 0 39 0
2 0 39 30
2 1 6 20
2 1 20 1
2 1 20 31
3 2 15 0
3 2 59 30
4 0 28 48
5 1 5 40
5 1 6 10
5 1 7 41
11 0 55 0
0 0 0 0

样例输出 1

0 0 43200 1427
0 0 43200 1427
1 56 4080 1427
1 56 47280 1427
1 57 4860 1427
3 10 18600 1427
3 10 61800 1427
7 18 39240 1427
7 18 82440 1427
7 23 43140 1427
7 24 720 1427
0 38 4680 79
0 39 2340 79
0 40 0 1
1 6 3960 79
1 20 2400 79
1 21 60 79
2 15 0 1
0 0 2700 89
0 28 48 1
1 6 320 33
1 6 40 1
1 8 120 11
0 55 0 1

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.