#include <iostream> #include <string> using namespace std; string s; int main() { ios::sync_with_stdio(false); cin >> s; int sam = 0; int spo = 0; long long int res = 0; int last = 0; int l = s.size(); for(int i = 0; i < s.size(); i++) { char c = s[i]; if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'y') { sam++; spo = 0; } else { spo++; sam = 0; } if(sam >= 3 || spo >= 3) { res += ((i - 1) - last) * (l - i); last = i - 1; } } cout << res; 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 | #include <iostream> #include <string> using namespace std; string s; int main() { ios::sync_with_stdio(false); cin >> s; int sam = 0; int spo = 0; long long int res = 0; int last = 0; int l = s.size(); for(int i = 0; i < s.size(); i++) { char c = s[i]; if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'y') { sam++; spo = 0; } else { spo++; sam = 0; } if(sam >= 3 || spo >= 3) { res += ((i - 1) - last) * (l - i); last = i - 1; } } cout << res; return 0; } |