#include "bits/stdc++.h" using namespace std; int main() { ios_base::sync_with_stdio(0); string s; cin >> s; long long n = s.size(); vector<bool> b(n); for (int i = 0; i < n; ++i) { for (int j = 0; j < 6; ++j) { if(s[i] == "aeiouy"[j]) b[i] = true; } } long long easy_count = 0; int len = 0; for (int i = 0; i <= n; ++i) { if (i < 3 || b[i-2] != b[i-1] || b[i-3] != b[i-1]) ++len; else len = 3; easy_count += len; } cout << (n+2) * (n+1) / 2 - easy_count << '\n'; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | #include "bits/stdc++.h" using namespace std; int main() { ios_base::sync_with_stdio(0); string s; cin >> s; long long n = s.size(); vector<bool> b(n); for (int i = 0; i < n; ++i) { for (int j = 0; j < 6; ++j) { if(s[i] == "aeiouy"[j]) b[i] = true; } } long long easy_count = 0; int len = 0; for (int i = 0; i <= n; ++i) { if (i < 3 || b[i-2] != b[i-1] || b[i-3] != b[i-1]) ++len; else len = 3; easy_count += len; } cout << (n+2) * (n+1) / 2 - easy_count << '\n'; } |