#include <iostream> using namespace std; bool vow[256]; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); string s; cin >> s; for (char c : {'a', 'e', 'i', 'o', 'u', 'y'}) vow[c] = true; int p = 0; long long res = 0; for (int i = 1; i < (int)s.size() - 1; ++i) if (vow[s[i - 1]] == vow[s[i]] and vow[s[i]] == vow[s[i + 1]]) res += (long long)(i - p) * (s.size() - (i + 1)), p = i; cout << res << '\n'; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | #include <iostream> using namespace std; bool vow[256]; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); string s; cin >> s; for (char c : {'a', 'e', 'i', 'o', 'u', 'y'}) vow[c] = true; int p = 0; long long res = 0; for (int i = 1; i < (int)s.size() - 1; ++i) if (vow[s[i - 1]] == vow[s[i]] and vow[s[i]] == vow[s[i + 1]]) res += (long long)(i - p) * (s.size() - (i + 1)), p = i; cout << res << '\n'; } |