#include<iostream> using namespace std; bool isVowel(char z){ if (z == 'a' || z == 'e' || z == 'i' || z == 'o' || z == 'u' || z == 'y') return 1; return 0; } int main(){ long long temp = 0, ans = 0; int last = -1, count_the_same = 0, vowel_now = false; string s; cin >> s; for(int i=0; i<s.size(); i++){ if(isVowel(s[i]) != vowel_now){ count_the_same = 0; vowel_now = !vowel_now; } count_the_same += 1; if(count_the_same >= 3){ temp += i - last - 2; last = i - 2; } ans += temp; } cout << ans; }
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 | #include<iostream> using namespace std; bool isVowel(char z){ if (z == 'a' || z == 'e' || z == 'i' || z == 'o' || z == 'u' || z == 'y') return 1; return 0; } int main(){ long long temp = 0, ans = 0; int last = -1, count_the_same = 0, vowel_now = false; string s; cin >> s; for(int i=0; i<s.size(); i++){ if(isVowel(s[i]) != vowel_now){ count_the_same = 0; vowel_now = !vowel_now; } count_the_same += 1; if(count_the_same >= 3){ temp += i - last - 2; last = i - 2; } ans += temp; } cout << ans; } |