#include <cstdio> #include <cstring> char buf[200009]; bool tab[200009]; bool vowel(char c) { return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'y'; } int main() { scanf("%s", buf); int l = strlen(buf); if (l < 3) { printf("0\n"); return 0; } long long sumx = 0; long long nzeros = 0; for (int i=0; i<l-2; i++) { int sum = vowel(buf[i]) + vowel(buf[i+1]) + vowel(buf[i+2]); if (sum == 0 || sum == 3) { sumx += nzeros * (nzeros + 1) / 2; nzeros = 0; } else { nzeros++; } } sumx += nzeros * (nzeros + 1) / 2; long long nn = l - 2; printf("%lld\n", nn * (nn+1) / 2 - sumx); }
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 <cstdio> #include <cstring> char buf[200009]; bool tab[200009]; bool vowel(char c) { return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'y'; } int main() { scanf("%s", buf); int l = strlen(buf); if (l < 3) { printf("0\n"); return 0; } long long sumx = 0; long long nzeros = 0; for (int i=0; i<l-2; i++) { int sum = vowel(buf[i]) + vowel(buf[i+1]) + vowel(buf[i+2]); if (sum == 0 || sum == 3) { sumx += nzeros * (nzeros + 1) / 2; nzeros = 0; } else { nzeros++; } } sumx += nzeros * (nzeros + 1) / 2; long long nn = l - 2; printf("%lld\n", nn * (nn+1) / 2 - sumx); } |