No.296 n-Time Sleeper
タグ : / 解いたユーザー数 884
作問者 :
data9824
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
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もしくは右上の雲マークをクリックしてアカウントを作成してください。