-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtask_1225.cpp
More file actions
29 lines (24 loc) · 805 Bytes
/
task_1225.cpp
File metadata and controls
29 lines (24 loc) · 805 Bytes
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
#include <iostream>
#include <vector>
#include <array>
const int NUM_COLORS = 3;
// 0 - red
// 1 - white
// 2 - blue
int main() {
int num_stripes;
std::cin >> num_stripes;
std::vector<std::array<uint64_t, 2>> combinations(static_cast<size_t>(num_stripes));
combinations[0] = {1, 1};
for(int i = 1; i < num_stripes; i++) {
for(int last_stripe_color=0; last_stripe_color < 2; last_stripe_color++) {
combinations[i][last_stripe_color] = combinations[i-1][1 - last_stripe_color];
if (i > 1) {
combinations[i][last_stripe_color] += combinations[i - 2][1 - last_stripe_color];
}
}
}
uint64_t result = combinations[num_stripes - 1][0] + combinations[num_stripes - 1][1];
std::cout << result;
return 0;
}