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:
        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, sr, sc; cin >> r; cin >> c; int p[r][c]; bool v

CCC '24 J4 - Troublesome Keys

#include <iostream> #include <string> #include <map> #include <vector> #include <algorithm> #include <cmath> using namespace std; int main() { string ps; string ds; cin >> ps; cin >> ds;

CCC '22 J5 - Square Pool

#include<iostream> #include <vector> #include <algorithm> #include <cmath> using namespace std; bool rowcom(pair<int, int> a, pair<int, int> b){ return a.first < b.first; } bool colcom(pair<int,


bottom of page