#include <iostream> #include <string> using namespace std; char samo[] = {'a','e','i','o','u','y'}; int samotny(char c) { for (int i = 0 ; i < 6 ;i ++) if (samo[i] == c) return true; return false; } int main() { ios::sync_with_stdio(false); string s; cin >> s; long long sum = 0; int j = -1; for (int i = 0 ; i < s.length() - 2 ; i++) { int su = samotny(s[i]) + samotny(s[i+1]) + samotny(s[i+2]); if (su == 0 || su == 3) { sum += (long long) (i - j) * (long long)(s.length() - i - 2); j = i; } } cout << 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 26 27 28 29 | #include <iostream> #include <string> using namespace std; char samo[] = {'a','e','i','o','u','y'}; int samotny(char c) { for (int i = 0 ; i < 6 ;i ++) if (samo[i] == c) return true; return false; } int main() { ios::sync_with_stdio(false); string s; cin >> s; long long sum = 0; int j = -1; for (int i = 0 ; i < s.length() - 2 ; i++) { int su = samotny(s[i]) + samotny(s[i+1]) + samotny(s[i+2]); if (su == 0 || su == 3) { sum += (long long) (i - j) * (long long)(s.length() - i - 2); j = i; } } cout << sum; return 0; } |