#include <cstring> #include <iostream> using namespace std; char spol[10] = {'a', 'e', 'i', 'o', 'u', 'y'}; string s; long long wyn; bool isSpol(int in) { char c = s[in]; for (int i = 0; i < 6; i++) if (c == spol[i]) return true; return false; } int main() { cin >> s; int n = s.size(); int last = -1; for (int i = 2; i < n; i++) { int ret = isSpol(i) + isSpol(i-1) + isSpol(i-2); if (ret == 0 || ret == 3) { last = i - 2; wyn += i - 1; } else if(last != -1) { wyn += last + 1; } } printf("%lld\n", wyn); }
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 | #include <cstring> #include <iostream> using namespace std; char spol[10] = {'a', 'e', 'i', 'o', 'u', 'y'}; string s; long long wyn; bool isSpol(int in) { char c = s[in]; for (int i = 0; i < 6; i++) if (c == spol[i]) return true; return false; } int main() { cin >> s; int n = s.size(); int last = -1; for (int i = 2; i < n; i++) { int ret = isSpol(i) + isSpol(i-1) + isSpol(i-2); if (ret == 0 || ret == 3) { last = i - 2; wyn += i - 1; } else if(last != -1) { wyn += last + 1; } } printf("%lld\n", wyn); } |