#include<iostream> using namespace std; bool isVovel(char c) { return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'y'; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); string input; cin >> input; long long result = 0; int length = input.length(); if(length < 3) { cout << result << "\n"; } else { bool previous, current = isVovel(input[0]); int range = 1, left = 0, right = 0; for(int i=1; i<length; i++) { right++; previous = current; current = isVovel(input[i]); if(previous == current) range++; else range = 1; if(range>2) { result += (right-left-1)*(length-right); left = right-1; } } cout << result << "\n"; } 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> using namespace std; bool isVovel(char c) { return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'y'; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); string input; cin >> input; long long result = 0; int length = input.length(); if(length < 3) { cout << result << "\n"; } else { bool previous, current = isVovel(input[0]); int range = 1, left = 0, right = 0; for(int i=1; i<length; i++) { right++; previous = current; current = isVovel(input[i]); if(previous == current) range++; else range = 1; if(range>2) { result += (right-left-1)*(length-right); left = right-1; } } cout << result << "\n"; } return 0; } |