102781: [AtCoder]ABC278 B - Misjudge the Time

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:7 Solved:0

Description

Score : $200$ points

Problem Statement

Takahashi bought a table clock.
The clock shows the time as shown in Figure 1 at $\mathrm{AB}$:$\mathrm{CD}$ in the $24$-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 $m$ minutes past $h$ in the $24$-hour system. Here, the $24$-hour system represents the hour by an integer between $0$ and $23$ (inclusive), and the minute by an integer between $0$ and $59$ (inclusive).
Let $A$ be the tens digit of $h$, $B$ be the ones digit of $h$, $C$ be the tens digit of $m$, and $D$ be the ones digit of $m$. (Here, if $h$ has only one digit, we consider that it has a leading zero; the same applies to $m$.)
Then, the clock shows $A$ in its top-left, $B$ in its bottom-left, $C$ in its top-right, and $D$ 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 $24$-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 $H$:$M$.
Find the next confusing time (including now) in the $24$-hour system.

Constraints

  • $0 \leq H \leq 23$
  • $0 \leq M \leq 59$
  • $H$ and $M$ are integers.

Input

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

$H$ $M$

Output

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

$h$ $m$

Your answer is considered correct even if $h$ contains a leading zero to represent it as a $2$-digit integer; the same applies to $m$.


Sample Input 1

1 23

Sample Output 1

1 23

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.


Sample Input 2

19 57

Sample Output 2

20 0

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


Sample Input 3

20 40

Sample Output 3

21 0

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

Input

题意翻译

### 题目描述 高桥买了个台钟。这个钟采用 24 小时计时法,显示的时间为 $\overline{AB}:\overline{CD}$。当且仅当 $0\leq \overline {AB}<24$ 且 $0\leq \overline {CD}<60$ 时我们称这个时间是合法的。 高桥决定将满足以下条件的时间叫做 “**迷惑时间**”: + 如果把 $B$ 和 $C$ 交换,这个时间仍然是合法的。 比如说 20:13 是“**迷惑时间**”,因为 21:03 是合法的。 现在高桥的钟显示的时间是 $H:M$。请你求出从现在之后离现在最近的“**迷惑时间**”(包括现在)。 ### 输入格式 输入格式如下: >$H\quad M$ ### 输出格式 设答案是 $h:m$,那么请你输出: >$h\quad m$ 输出允许 $h$ 存在前导 $0$。 ### 说明/提示 #### 数据范围 + $0\leq H\leq 23$ + $0\leq M\leq 59$ + $H$ 和 $M$ 是整数 #### 样例解释 + **样例 1** 1:23 是一个“**迷惑时间**”,因为 2:13 是合法的。因此答案就是 1:23。 当然,即使你输出 ```01 23``` 也是可以的。 + **样例 2** 19:57 后的下一个“**迷惑时间**”是 20:00。 + **样例 3** 请注意 24:00 是不合法的时间。

Output

得分:200分 部分 问题描述 Takahashi 买了一个钟表。 该钟表在24小时制下显示时间,如图1中的AB:CD所示。 例如,图2中的钟表显示的时间是7:58。 时间的格式正式描述如下。 假设当前时间是24小时制下的h分钟过去的m。这里,24小时制用0到23(包括)之间的整数表示小时,用0到59(包括)之间的整数表示分钟。 设A为h的十位数,B为h的个位数,C为m的十位数,D为m的个位数。(在这里,如果h只有一个数字,我们假设它有一个前导零;m也是如此。) 那么,钟表的左上显示A,左下显示B,右上显示C,右下显示D。 现在,Takahashi决定将满足以下条件的时间称为"令人困惑的时间": 在钟表上交换右上和左下两位数字后,它仍然表示24小时制下的有效时间。 例如,图3中的钟表显示的时间是20:13。交换其右上和左下两位数字后,它变为21:03。因此,20:13是一个令人困惑的时间。 现在,钟表显示的时间为H:M。 在24小时制下找到下一个令人困惑的时间(包括现在)。 部分 约束 * 0 <= H <= 23 * 0 <= M <= 59 * H和M是整数。 部分 输入 输入以标准输入的以下格式给出: H M 部分 输出 设答案为h:m,其中h和m必须满足0 <= h <= 23和0 <= m <= 59。 以下格式打印h和m: h m 即使h包含一个前导零来表示它是一个2位整数,您的答案也会被认为是正确的;m也是如此。 部分 样例输入1 1 23 部分 样例输出1 1 23 1:23是一个令人困惑的时间,因为在钟表上交换其右上和左下两位数字后,它变为2:13。 因此,答案是1:23。 即使您打印01 23(带前导零),您的答案也会被认为是正确的。 部分 样例输入2 19 57 部分 样例输出2 20 0 19:57之后的下一个令人困惑的时间是20:00。 部分 样例输入3 20 40 部分 样例输出3 21 0 注意24:00不是24小时制的有效表示。

加入题单

算法标签: