0% found this document useful (0 votes)
120 views

Getproblem (4) S

Wendy enjoys finding times on her LED clock radio where the digits form an arithmetic sequence. The problem describes Wendy's clock and defines an arithmetic sequence. It asks how many times within a given duration starting at 12:00 PM will display a time where the digits are in an arithmetic sequence. Sample inputs and outputs are provided to illustrate counting the number of such times for different durations.

Uploaded by

Ali Patel
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
120 views

Getproblem (4) S

Wendy enjoys finding times on her LED clock radio where the digits form an arithmetic sequence. The problem describes Wendy's clock and defines an arithmetic sequence. It asks how many times within a given duration starting at 12:00 PM will display a time where the digits are in an arithmetic sequence. Sample inputs and outputs are provided to illustrate counting the number of such times for different durations.

Uploaded by

Ali Patel
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Problem J4: Favourite Times

Time limit: 1 second


Problem Description
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 Specification
The input contains one integer D (0 D 1 000 000 000), which represents the duration that the
clock is observed.
For 4 of the 15 available marks, D 10 000.

Output Specification
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

Output for Sample Input 1


1

Explanation of Output for Sample Input 1


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

Sample Input 2
180

Output for Sample Input 2


11

Version francaise sont apres la version anglaise


Explanation of Output for Sample Input 2
Between 12:00 and 3:00, the following times form arithmetic sequences in their digits (with
the difference shown:

12:34 (difference 1),

1:11 (difference 0),

1:23 (difference 1),

1:35 (difference 2),

1:47 (difference 3),

1:59 (difference 4),

2:10 (difference -1),

2:22 (difference 0),

2:34 (difference 1),

2:46 (difference 2),

2:58 (difference 3).

Version francaise sont apres la version anglaise


Probleme J4 : Heures preferees
Description du probleme
Wendy a un radio-reveil a affichage LED qui affiche lheure de 12:00 a 11:59. Les heures nont
pas de zero initial, mais les minutes peuvent en avoir un. Par exemple, 2:07 ou 11:03.
Lorsquelle regarde lheure, Wendy prend un plaisir fou a trouver une suite arithmeque dans les
chiffres. Par exemple, 12:34 et 2:46 sont deux de ses heures preferees, car a chacune de ces
heures les chiffres forment une suite arithmetique.
Une suite de chiffres forme une suite arithmetique si chaque chiffre apres le premier est obtenu en
ajoutant une constante (appelee raison arithmetique) au terme precedent. Par exemple, 1, 2, 3, 4
est une suite arithmetique dont la raison est 1, tandis que 2, 4, 6 est une suite arithmetique dont la
raison est 2.
Supposons que lon commence a regarder le reveil a midi (lorsquil affiche 12:00) et quon le
regarde pendant un certain nombre de minutes. Combien y a-t-il doccasions ou les chiffres de
lheure affichee forment une suite arithmetique ?

Precisions par rapport aux entrees


Lentier contiendra un entier D (0 D 1 000 000 000), qui represente la duree du temps
dobservation du reveil en minutes.
Pour 4 des 15 points disponibles, on aura D 10 000.

Precisions par rapport aux sorties


La sortie sera le nombre de fois que le reveil affiche une heure dont les chiffres forment une suite
arithmetique a partir de midi (12:00) jusqua D minutes plus tard, y compris la derniere heure
affichee.

Exemple dentree 1
34

Sortie pour lexemple dentree 1


1

Explication de la sortie pour lexemple dentree 1


De 12:00 a 12:34, seule lheure 12:34 a des chiffres qui forment une suite arithmetique.

Exemple dentree 2
180

Sortie pour lexemple dentree 2


11

English version appears before the French version


Explication de la sortie pour lexemple dentree 2
De 12:00 a 3:00, les chiffres des heures suivantes forment une suite arithmetique (la raison de
chaque suite est indiquee) :
12:34 (raison 1),
1:11 (raison 0),
1:23 (raison 1),
1:35 (raison 2),
1:47 (raison 3),
1:59 (raison 4),
2:10 (raison -1),
2:22 (raison 0),
2:34 (raison 1),
2:46 (raison 2),
2:58 (raison 3).

English version appears before the French version

You might also like