## CCC '17 J4 - Favourite Times

View as PDF

Points: 5 (partial)
Time limit: 1.0s
Memory limit: 256M

Problem type
##### Canadian Computing Competition: 2017 Stage 1, Junior #4

Wendy has an LED clock radio, which is a 12-hour clock, displaying times from to . The hours do not have leading zeros but minutes may have leading zeros, such as or .

When looking at her LED clock radio, Wendy likes to spot arithmetic sequences in the digits. For example, the times and are some of her favourite times, since the digits form an arithmetic sequence.

A sequence of digits is an arithmetic sequence if each digit after the first digit is obtained by adding a constant common difference. For example, is an arithmetic sequence with a common difference of , and is an arithmetic sequence with a common difference of .

Suppose that we start looking at the clock at noon (that is, when it reads ) and watch the clock for some number of minutes. How many instances are there such that the time displayed on the clock has the property that the digits form an arithmetic sequence?

#### Input Specification

The input contains one integer , which represents the duration that the clock is observed.

For 4 of the 15 available marks, .

#### Output Specification

Output the number of times that the clock displays a time where the digits form an arithmetic sequence starting from noon () and ending after minutes have passed, possibly including the ending time.

#### Sample Input 1

34

#### Sample Output 1

1

#### Explanation for Sample Output 1

Between and , there is only the time for which the digits form an arithmetic sequence.

#### Sample Input 2

180

#### Sample Output 2

11

#### Explanation for Sample Output 2

Between and , the following times form arithmetic sequences in their digits (with the difference shown):

• (difference 1),
• (difference 0),
• (difference 1),
• (difference 2),
• (difference 3),
• (difference 4),
• (difference -1),
• (difference 0),
• (difference 1),
• (difference 2),
• (difference 3).

• commented on Oct. 10, 2022, 2:23 a.m.

How can I fix the TLE problem?

• commented on Oct. 10, 2022, 11:31 a.m.

How many such arithmetic sequences appear in the 12-hour (720-minute) cycle?

If the input exceeds 720, do we really need to compute all the arithmetic sequences? Won't that take too long?

This is why you TLE.

• commented on Jan. 20, 2022, 6:58 p.m.

can anybody check my latest submission

• commented on Jan. 20, 2022, 8:22 p.m.

Test cases like 900, 3600 and 6969 fail

• commented on Feb. 1, 2022, 1:06 p.m. edit 5

What would be the answer, mine is 42, 156 and 309 and DMOJ says mine is wrong┭┮﹏┭┮

• commented on May 14, 2022, 11:56 a.m. edited

D:

• commented on Feb. 2, 2021, 10:19 p.m.

What a shame "6:66" isn't a thing.

• commented on Feb. 10, 2020, 4:58 p.m.

Wow! 2017 was filled with Math questions! Interesting.

• commented on May 24, 2019, 8:51 p.m.

I keep getting tle at start of batch#3 help

• commented on May 25, 2019, 1:13 a.m.

D has a max value of 1 billion. Looping through all values is too slow

• commented on June 23, 2018, 2:46 p.m. edited

The perfect way to describe this question: observing a clock for up to 1901 years. Hmmm... Not bad ill just see how many times my favourite number comes on! Oh btw my favourite number are only patterns how sad

• commented on Jan. 19, 2022, 6:39 p.m. edit 2

lol, imagine doing that

• commented on Sept. 1, 2017, 8:35 p.m.

No j5?