P8547 Xiao Wa’s Time
Description
Xiao Wa has a digital clock that uses a $12$-hour format and shows only hours and minutes, i.e., it only displays $12:00 \sim 11:59$. The time after $12:59$ is $1:00$.
The hour has no leading zero, but the minutes may have one (for example, $7:59$ will not be written as $07:59$, while $10:03$ will not be written as $10:3$).
Starting from **noon** of some day (i.e., $12:00$), Xiao Wa stares at this digital clock for a total of $T$ minutes. They now want to know: how many times in total will they see a time whose digits form an **arithmetic progression**?
The definition of an **arithmetic progression** is as follows: if a sequence is an arithmetic progression, then every number after the first equals the previous one plus a fixed common difference. For example, $11:11$ is such a time with common difference $0$, and $12:34$ is such a time with common difference $1$.
If you look carefully, you will notice that the common difference is not restricted in sign, so it can be positive or negative.
Input Format
Line $1$: a positive integer $D$, meaning this test point contains $D$ groups of testdata.
Lines $2 \sim D + 1$: each line contains a non-negative integer $T$, with the meaning described above.
Output Format
Output $D$ lines in total. Each line contains an integer $ans$, representing the number of arithmetic-progression times seen.
Explanation/Hint
For $30\%$ of the data, $0 \leq T \leq 60$.
For $60\%$ of the data, $0 \leq T \leq 10^5$.
For $100\%$ of the data, $0 \leq T \leq 10^9$, $1 \leq D \leq 500$.
#### Sample Explanation
For the first query $34$, the interval is from $12:00 \sim 12:34$. Only $12:34$ satisfies the requirement.
For the third query $100$, the interval is from $12:00 \sim 1:40$. There are four times that satisfy the requirement: $12:34, 1:11, 1:23, 1:35$.
For the fourth query $118$, the interval is from $12:00 \sim 1:58$. There are five times that satisfy the requirement: $12:34, 1:11, 1:23, 1:35, 1:47$.
Translated by ChatGPT 5