#include <cstdio> #include <cstring> char X[200001]; char M[] = { 'a', 'e', 'i', 'o', 'u', 'y' }; int test(int idx) { int res = 0; for (int i = 0; i<3; i++) for (int j = 0; j<6; j++) { res += (X[idx - i] == M[j]); } return res; } int main() { scanf("%s", X); int n = strlen(X); long long int count = 0; int last = 1; for (int i = 2; i<n; i++) { int r = test(i); if (r == 0 || r == 3) { count += (n - i)*(i - last); last = i; } } printf("%lld\n", count); 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 | #include <cstdio> #include <cstring> char X[200001]; char M[] = { 'a', 'e', 'i', 'o', 'u', 'y' }; int test(int idx) { int res = 0; for (int i = 0; i<3; i++) for (int j = 0; j<6; j++) { res += (X[idx - i] == M[j]); } return res; } int main() { scanf("%s", X); int n = strlen(X); long long int count = 0; int last = 1; for (int i = 2; i<n; i++) { int r = test(i); if (r == 0 || r == 3) { count += (n - i)*(i - last); last = i; } } printf("%lld\n", count); return 0; } |