#include <cstdio> char s[200005]; bool vowel[26]; int main() { for (char c='a'; c<='z'; c++) vowel[c-'a'] = (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'y'); scanf("%s", s); long long res = 0; int active = 0, last = -1, state = 0; for (int i=0; s[i]; i++) { state = (2 * state + vowel[s[i]-'a']) % 8; if (i >= 2 && (state == 0 || state == 7)) { active += i-2-last; last = i-2; } res += active; } printf("%lld\n", res); return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | #include <cstdio> char s[200005]; bool vowel[26]; int main() { for (char c='a'; c<='z'; c++) vowel[c-'a'] = (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'y'); scanf("%s", s); long long res = 0; int active = 0, last = -1, state = 0; for (int i=0; s[i]; i++) { state = (2 * state + vowel[s[i]-'a']) % 8; if (i >= 2 && (state == 0 || state == 7)) { active += i-2-last; last = i-2; } res += active; } printf("%lld\n", res); return 0; } |