1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
#include <iostream>
// Up to (but not including) this value of minutes there are 'i' arithmetic
// sequences, where 'i' is the index at that point in the array.
// The newly-added sequence is shown in the comment.
// E.g., up to (but not including) 201 minutes there are 11 sequences.
// The 'UpTo' minutes are just the minute-counts of the next sequence,
// e.g., 201 comes from 3:21, i.e., 3 * 60 + 21.
const int UpTo[] {
34, // none
71, // 12:34
83, // 1:11
95, // 1:23
107, // 1:35
119, // 1:47
130, // 1:59
142, // 2:10
154, // 2:22
166, // 2:34
178, // 2:46
201, // 2:58
213, // 3:21
225, // 3:33
237, // 3:45
260, // 3:57
272, // 4:20
284, // 4:32
296, // 4:44
331, // 4:56
343, // 5:31
355, // 5:43
390, // 5:55
402, // 6:30
414, // 6:42
461, // 6:54
473, // 7:41
520, // 7:53
532, // 8:40
591, // 8:52
671, // 9:51
720 // 11:11
};
const int Size = sizeof UpTo / sizeof *UpTo;
// For every WrapAround minutes, there are Size - 1 sequences.
const int WrapAround = 60 * 12;
int main() {
int minutes{0};
std::cin >> minutes;
int n = minutes / WrapAround * (Size - 1);
int remainder = minutes % WrapAround;
for (int i = 0; i < Size; ++i)
if (remainder < UpTo[i]) {
n += i;
break;
}
std::cout << n << '\n';
}
| |