#include <cstdio> #include <cstring> using namespace std; bool v(char c) { return c == 'a' || c == 'e' || c == 'y' || c == 'u' || c == 'i' || c == 'o'; } int main() { char a[2000001]; scanf("%s", a); int n = strlen(a); int last = -1; long sum = 0; for (int i = 2; i < n; ++i) { if (v(a[i]) == v(a[i - 1]) && v(a[i]) == v(a[i - 2])) { last = i - 2; } if (last != -1) { sum += last + 1; } } printf("%ld\n", sum); 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 | #include <cstdio> #include <cstring> using namespace std; bool v(char c) { return c == 'a' || c == 'e' || c == 'y' || c == 'u' || c == 'i' || c == 'o'; } int main() { char a[2000001]; scanf("%s", a); int n = strlen(a); int last = -1; long sum = 0; for (int i = 2; i < n; ++i) { if (v(a[i]) == v(a[i - 1]) && v(a[i]) == v(a[i - 2])) { last = i - 2; } if (last != -1) { sum += last + 1; } } printf("%ld\n", sum); return 0; } |