#P11002. Magical Alarm Clock
Magical Alarm Clock
Magical Alarm Clock
A magical alarm clock was discovered by Xiao Lan. Starting from the epoch time (i.e. \(1970\text{-}01\text{-}01\ 00:00:00\)), the alarm clock rings every \(x\) minutes. That is, it rings at times \(T_k = \text{epoch} + k \times x \text{ minutes}\) for \(k \geq 0\).
Given an integer \(x\) and a time point in the format yyyy-MM-dd HH:mm:ss
, determine the most recent alarm time (which is less than or equal to the given time). The output should be in the same format as the input.
Note: You do not need to consider timezone issues.
inputFormat
The input consists of two lines. The first line contains an integer \(x\) (the alarm interval in minutes). The second line contains a time string in the format yyyy-MM-dd HH:mm:ss
.
outputFormat
Output the latest alarm time that is less than or equal to the given time, in the format yyyy-MM-dd HH:mm:ss
.
sample
10
1970-01-01 00:00:00
1970-01-01 00:00:00