#P8547. Arithmetic Sequence Time
Arithmetic Sequence Time
Arithmetic Sequence Time
You are given an electronic clock that displays time in a 12‐hour format. The clock shows hours and minutes only. The hours are displayed without a leading zero (e.g. 7:59
is shown as such, not as 07:59
), but the minutes always have two digits (for example, 10:03
is valid, not 10:3
). The clock displays times from \(12:00\) through \(11:59\). Note that after \(12:59\) the time becomes \(1:00\).
The time is considered as a sequence of digits obtained by concatenating the hour (without leading zero if it is one digit) and the minute (always two digits). For instance, \(12:34\) is viewed as the sequence \(1,2,3,4\) and \(7:11\) as \(7,1,1\).
A sequence is called an arithmetic sequence if every term after the first is obtained by adding a fixed constant (which may be positive, negative, or zero) to the previous term. For example, the digits in \(11:11\) (i.e. \(1,1,1,1\)) form an arithmetic sequence with a common difference of \(0\), and the digits in \(12:34\) form an arithmetic sequence with a common difference of \(1\).
Starting at noon (\(12:00\)), you watch the clock for \(T\) minutes (inclusive of the initial time). Your task is to determine how many times during this period the clock displays a time whose digits form an arithmetic sequence.
Note: Since \(T\) minutes includes the starting time at noon, if \(T = 0\) you only see \(12:00\).
inputFormat
The input consists of a single integer \(T\) (\(0 \le T \le 10^9\)), which is the number of minutes you watch the clock.
Input is read from standard input.
outputFormat
Output a single integer representing the number of times the clock displays an arithmetic sequence during the \(T\)-minute period (including the starting time).
Output to standard output.
sample
0
0