#include <iostream> using namespace std; bool isVowel(char c) { return (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'y'); } int main() { long long result = 0; string input; cin >> input; int vowel[3]; vowel[0] = vowel[1] = vowel[2] = 2; int prev = -1; for(int i = 0; i < input.size(); i++) { vowel[0] = vowel[1]; vowel[1] = vowel[2]; vowel[2] = isVowel(input[i]); if(vowel[0] == vowel[1] && vowel[1] == vowel[2]) { result += ((int)(input.size()) - i) * (i - 2 - prev); prev = i - 2; } } cout << result << endl; 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 | #include <iostream> using namespace std; bool isVowel(char c) { return (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'y'); } int main() { long long result = 0; string input; cin >> input; int vowel[3]; vowel[0] = vowel[1] = vowel[2] = 2; int prev = -1; for(int i = 0; i < input.size(); i++) { vowel[0] = vowel[1]; vowel[1] = vowel[2]; vowel[2] = isVowel(input[i]); if(vowel[0] == vowel[1] && vowel[1] == vowel[2]) { result += ((int)(input.size()) - i) * (i - 2 - prev); prev = i - 2; } } cout << result << endl; return 0; } |