問題一覧 > 通常問題

No.296 n-Time Sleeper

レベル : / AI推定難易度 : 115 / 実行時間制限 : 1ケース 1.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 884
作問者 : data9824
お気に入りにしたユーザー ProblemId : 822 / 自分の提出
問題文最終更新日: 2026-06-25 13:14:22
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 125 (順位表) の他の問題:

Problem Statement

Yuki is not a morning person. Even when the alarm on her alarm clock goes off, she can't help stopping it and going back to sleep for a 2nd time. The alarm clock repeats its alarm, but Yuki again stops it each time, going back to sleep for a 3rd time, a 4th time, ..., up to an $n$-th time before she finally gets up.

Given the time at which the alarm first goes off and the interval at which it goes off after that, find the time at which Yuki finally gets up, assuming she sleeps $n$ times.

Note the following points.

  • Sleeping $n$ times means that, after first waking up, she wakes up $n-1$ more times until she finally gets up.
  • Yuki always wakes up when the alarm goes off.
  • After first sounding its alarm, the alarm clock repeats the alarm at a fixed interval until Yuki finally gets up.
  • Except when she finally gets up, Yuki stops the alarm and goes back to sleep upon waking up. This action is assumed to finish in an instant.
  • Daylight saving time is not taken into account.

Input

N H M T
$1 \leq N \leq 1000000 = 10^6$
$0 \leq H \leq 23$
$0 \leq M \leq 59$
$1 \leq T \leq 1440 = 24 \times 60$
$N$ indicates that Yuki sleeps $N$ times.
$H$ is the hour value, in 24-hour notation, of the time at which the alarm first goes off.
$M$ is the minute value of the time at which the alarm first goes off.
$T$ is the interval, in minutes, at which the alarm repeats after it first goes off.

Output

Output the hour value in 24-hour notation and the minute value of the time at which Yuki finally gets up, separated by a newline. Print a newline at the end.

The hour value must be between 0 and 23, inclusive. Except when the value is 0, the value must not have a leading 0.

Sample

Sample 1
Input
2 7 30 5
Output
7
35

She could not get up at the 7:30 alarm and went back to sleep for a 2nd time. In the end, she finally got up at 7:35, when the alarm next went off.

Sample 2
Input
1 8 0 5
Output
8
0

She was able to get up after the 8:00 alarm went off just once.

Sample 3
Input
7 8 0 5
Output
8
30

She could not get up at the 8:00 alarm and ended up sleeping 7 times. In the end, she finally got up at 8:30.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。