a892: Favourite Times
Tags : for if 字串 窮舉 累加 迴圈 運算
Accepted rate : 13人/15人 ( 87% ) [非即時]
評分方式:
Tolerant

最近更新 : 2022-11-24 09:59

Content

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

When looking at her LED clock radio, Wendy likes to spot arithmetic sequences in the digits. For example, the times 12:34 and 2:46 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, 1,2,3,4 is an arithmetic sequence with a common difference of 1, and 2,4,6 is an arithmetic sequence with a common difference of 2.

Suppose that we start looking at the clock at noon (that is, when it reads 12:00) 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

The input contains one integer D (0 ≤ D ≤ 1 000 000 000), which represents the duration that the clock is observed. 

Output

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

Sample Input #1
34
Sample Output #1
1
Sample Input #2
180
Sample Output #2
11
測資資訊:
記憶體限制: 64 MB
公開 測資點#0 (6%): 1.0s , <1K
公開 測資點#1 (6%): 0.6666666666666666s , <1K
公開 測資點#2 (6%): 0.6666666666666666s , <1K
公開 測資點#3 (6%): 0.6666666666666666s , <1K
公開 測資點#4 (6%): 0.6666666666666666s , <1K
公開 測資點#5 (7%): 0.6666666666666666s , <1K
公開 測資點#6 (7%): 0.6666666666666666s , <1K
公開 測資點#7 (7%): 0.6666666666666666s , <1K
公開 測資點#8 (7%): 0.6666666666666666s , <1K
公開 測資點#9 (7%): 0.6666666666666666s , <1K
公開 測資點#10 (7%): 0.6666666666666666s , <1K
公開 測資點#11 (7%): 0.6666666666666666s , <1K
公開 測資點#12 (7%): 0.6666666666666666s , <1K
公開 測資點#13 (7%): 0.6666666666666666s , <1K
公開 測資點#14 (7%): 0.6666666666666666s , <1K
Hint :
Tags:
for if 字串 窮舉 累加 迴圈 運算
出處:
CCC2017 [管理者:
issin@g.puic... (冼一心老師)
]


ID User Problem Subject Hit Post Date
沒有發現任何「解題報告」