#include <bits/stdc++.h> using namespace std; const int N = 200002; char s[N]; bool samogloska(char c) { if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'y') { return true; } return false; } int main() { scanf("%s", s); int n = strlen(s); long long ans = 0; int last = -1; for (int i = 0; i < n - 2; i++) { int cnt = 0; for (int j = 0; j < 3; j++) { if (samogloska(s[i+j])) cnt++; } if (cnt == 0 || cnt == 3) { ans += 1LL * (i - last) * (n - 2 - i); last = i; } } printf("%lld\n", ans); 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 30 31 32 33 | #include <bits/stdc++.h> using namespace std; const int N = 200002; char s[N]; bool samogloska(char c) { if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'y') { return true; } return false; } int main() { scanf("%s", s); int n = strlen(s); long long ans = 0; int last = -1; for (int i = 0; i < n - 2; i++) { int cnt = 0; for (int j = 0; j < 3; j++) { if (samogloska(s[i+j])) cnt++; } if (cnt == 0 || cnt == 3) { ans += 1LL * (i - last) * (n - 2 - i); last = i; } } printf("%lld\n", ans); return 0; } |