top of page

CCC 2017 J4: Exactly Electrical

The question asks to compute all arithmetic sequences.

Because the clock is a 12-hour clock, one-half day has 31 arithmetic sequences, you can write all, for example, 12:34, 1:11, 1:23...2:22...11:11, etc. And 12 hours are 720 minutes.

So if the input is d minutes, one 12-hour block is d//720, total arithmetic sequences are (d//720)*31, the remind minutes are d%720, the question becomes you can count the remind minutes' arithmetic sequences. The start point is 12:00.

So compose of the hour first, then place the minutes, and check if it is an arithmetic sequence one by one.

If the number of reminding minutes' arithmetic sequence is cnt. The final result is cnt + (d//720)*31.


day_c = 31
h_c = 720

d = int(input())
h = 12
m = 0
cnt = 0
for i in range(d % h_c):
    m += 1
    if m == 60:
        h += 1
        m = 0
    if h == 13:
        h = 1
    clock = str(h) + '%02d' % m
    dif = int(clock[1]) - int(clock[0])
    for j in range(1, len(clock)):
        if int(clock[j]) - int(clock[j - 1]) != dif:
            break
    else:
        cnt += 1
print(cnt + day_c * (d // h_c))

Recent Posts

See All

CCC '24 J5 - Harvest Waterloo

#include<iostream> #include <vector> #include <algorithm> #include <cmath> #include <stack> using namespace std; int main() { int r, c,...

CCC '24 J4 - Troublesome Keys

s1 = input() s2 = input() silly = '' silly_o = '' quiete = '-' i = 0 j = 0 while i < len(s1) and j < len(s2): if s1[i] != s2[j]: if...

CCC '22 J5 - Square Pool

#include<iostream> #include <vector> #include <algorithm> #include <cmath> using namespace std; bool rowcom(pair<int, int> a, pair<int,...

Comments


One-time Donations
I hope I can solve all CCC problems!,
Please e-transfer cccottawa862008@gmail.com

Subscribe to AIOICode newsletter

I'm a title. ​Click here to edit me.

Thanks for submitting!

  • Twitter
  • Facebook
  • Linkedin

© 2023 by AIOICode.

bottom of page