Misjudge the Time

 1 Sec 256 MB |  Markdown 获取标签
141527
通过人数尝试人数总提交数

 

题目描述

Takahashi bought a table clock.
The clock shows the time as shown in Figure 1 at AB\mathrm{AB}:CD\mathrm{CD} in the 2424-hour system.
For example, the clock in Figure 2 shows 7:58.

The format of the time is formally described as follows.
Suppose that the current time is mm minutes past hh in the 2424-hour system. Here, the 2424-hour system represents the hour by an integer between 00 and 2323 (inclusive), and the minute by an integer between 00 and 5959 (inclusive).
Let AA be the tens digit of hh, BB be the ones digit of hh, CC be the tens digit of mm, and DD be the ones digit of mm. (Here, if hh has only one digit, we consider that it has a leading zero; the same applies to mm.)
Then, the clock shows AA in its top-left, BB in its bottom-left, CC in its top-right, and DD in its bottom-right.

image

Takahashi has decided to call a time a confusing time if it satisfies the following condition:

  • after swapping the top-right and bottom-left digits on the clock, it still reads a valid time in the 2424-hour system.

For example, the clock in Figure 3 shows 20:13. After swapping its top-right and bottom-left digits, it reads 21:03. Thus, 20:13 is a confusing time.

The clock now shows HH:MM.
Find the next confusing time (including now) in the 2424-hour system.

输入格式

The input is given from Standard Input in the following format:

HH MM

Constraints

  • 0H230 \leq H \leq 23
  • 0M590 \leq M \leq 59
  • HH and MM are integers.

输出格式

Let hh:mm be the answer, where hh and mm must satisfy 0h230 \leq h \leq 23 and 0m590 \leq m \leq 59.
Print hh and mm in the following format:

hh mm

Your answer is considered correct even if hh contains a leading zero to represent it as a 22-digit integer; the same applies to mm.

样例输入 #1

1 23

样例输出 #1

1 23

样例输入 #2

19 57

样例输出 #2

20 0

样例输入 #3

20 40

样例输出 #3

21 0

提示

For Sample #1:

1:23 is a confusing time because, after swapping its top-right and bottom-left digits on the clock, it reads 2:13.
Thus, the answer is 1:23.
Your answer is considered correct even if you print 01 23 with a leading zero.

For Sample #2:

The next confusing time after 19:57 is 20:00.

For Sample #3:

Note that 24:00 is an invalid notation in the 2424-hour system.

来源

AtCoder [ABC278B]

 

 您尚未登录,无法进行代码提交

2023 ACM 协会新生国庆四天乐(四)

2023-10-04 14:00
2023-10-04 17:00
Ended