#include <iostream>
#include <queue>
using namespace std;
int cnt[2][3][2];
queue <int> q;
int main() {
int n; cin >> n;
for (int i = 0; i < 11; i++) {
int val; cin >> val; q.push(val);
}
int ans = 0;
for (int i = 11; i < n; i++) {
int last = q.front();
q.pop();
int idx2 = last % 3;
int idx3 = 0;
if (last > 33) {
idx3 = 1;
}
if (last % 5 == 0) {
cnt[0][idx2][idx3] += 1;
cnt[1][idx2][idx3] += 1;
} else {
cnt[1][idx2][idx3] += 1;
}
int cur; cin >> cur;
q.push(cur);
idx2 = (3 - cur % 3) % 3;
if (cur % 5 != 0) {
if (cur > 33) {
ans += cnt[0][idx2][0];
ans += cnt[0][idx2][1];
} else {
ans += cnt[0][idx2][1];
}
} else if (cur % 5 == 0) {
if (cur > 33) {
ans += cnt[0][idx2][0];
ans += cnt[0][idx2][1];
ans += cnt[1][idx2][0];
ans += cnt[1][idx2][1];
} else {
ans += cnt[0][idx2][1];
ans += cnt[1][idx2][1];
}
}
}
cout << ans << "\n";
return 0;
}
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.