#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); vector<int> T('z' + 1, 0); T['a'] = 1; T['e'] = 1; T['i'] = 1; T['o'] = 1; T['u'] = 1; T['y'] = 1; string S; cin >> S; int n = S.size(); int next = -1; long long res = 0; for (int i = n - 3; i >= 0; i--) { if (T[S[i]] == T[S[i + 1]] && T[S[i + 1]] == T[S[i + 2]]) next = i + 2; if (next != -1) res += n - next; } cout << res << endl; return 0; }
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 <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); vector<int> T('z' + 1, 0); T['a'] = 1; T['e'] = 1; T['i'] = 1; T['o'] = 1; T['u'] = 1; T['y'] = 1; string S; cin >> S; int n = S.size(); int next = -1; long long res = 0; for (int i = n - 3; i >= 0; i--) { if (T[S[i]] == T[S[i + 1]] && T[S[i + 1]] == T[S[i + 2]]) next = i + 2; if (next != -1) res += n - next; } cout << res << endl; return 0; } |