#include <iostream> #include <string> #include <map> #include <vector> using namespace std; typedef unsigned long long ULL; ULL count(int b, int e) { if (b < 1) b = 0; if (e < 1) e = 0; return (b + 1) * (e + 1); } bool is_vovel(char a) { if (a == 'a' || a == 'e' || a == 'i' || a == 'y' || a == 'o' || a == 'u') { return true; } return false; } //zwraca poczatek nastepnej 3 int find_next(string A, int i) { int c = 1; bool t = is_vovel(A[i]); i++; while (i < A.size()) { if (is_vovel(A[i]) == t) { c++; } else { c = 1; t = !t; } if (c == 3) { return i - 2; } i++; } return -1; } int main() { ios_base::sync_with_stdio(false); string A; getline(cin, A); ULL r = 0; int i = 0, n; int c = find_next(A, i); i = c + 1; while (c != -1) { int n = find_next(A, i); i = n + 1; if (n == -1) { r += count(c, A.size() - c - 3); } else { if (c != n) { } r += count(c, n - c - 1); } c = n; } cout << r << endl; 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 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | #include <iostream> #include <string> #include <map> #include <vector> using namespace std; typedef unsigned long long ULL; ULL count(int b, int e) { if (b < 1) b = 0; if (e < 1) e = 0; return (b + 1) * (e + 1); } bool is_vovel(char a) { if (a == 'a' || a == 'e' || a == 'i' || a == 'y' || a == 'o' || a == 'u') { return true; } return false; } //zwraca poczatek nastepnej 3 int find_next(string A, int i) { int c = 1; bool t = is_vovel(A[i]); i++; while (i < A.size()) { if (is_vovel(A[i]) == t) { c++; } else { c = 1; t = !t; } if (c == 3) { return i - 2; } i++; } return -1; } int main() { ios_base::sync_with_stdio(false); string A; getline(cin, A); ULL r = 0; int i = 0, n; int c = find_next(A, i); i = c + 1; while (c != -1) { int n = find_next(A, i); i = n + 1; if (n == -1) { r += count(c, A.size() - c - 3); } else { if (c != n) { } r += count(c, n - c - 1); } c = n; } cout << r << endl; return 0; } |