#include <cstdio> #include <string> #include <iostream> #include <vector> #define PB push_back using namespace std; int main() { int last = 0; long count = 0; vector<int> V; int vow = 0; int con = 0; int size = 0; int c; while ((c = getchar())) { if (c == EOF || c == '\n') { break; } if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'y') { vow++; con = 0; } else { con ++; vow = 0; } if (con > 2 || vow > 2) { V.PB(size - 2); } size++; } for (int i = 0; i< V.size(); ++i) { count = count + (V[i] - last + 1) * (size - V[i] - 2); last = V[i] + 1; } printf("%ld", 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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | #include <cstdio> #include <string> #include <iostream> #include <vector> #define PB push_back using namespace std; int main() { int last = 0; long count = 0; vector<int> V; int vow = 0; int con = 0; int size = 0; int c; while ((c = getchar())) { if (c == EOF || c == '\n') { break; } if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'y') { vow++; con = 0; } else { con ++; vow = 0; } if (con > 2 || vow > 2) { V.PB(size - 2); } size++; } for (int i = 0; i< V.size(); ++i) { count = count + (V[i] - last + 1) * (size - V[i] - 2); last = V[i] + 1; } printf("%ld", count); return 0; } |