#include <iostream>
#include <stdio.h>
#include <string>
int LEN = 3;
int isVowel(char ch){
int c = toupper(ch);
return (c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U'|| c == 'Y');
}
using namespace std;
int main(){
string str;
getline(cin,str);
long long lastResultMul = 0;
long long result = 0;
long long lastVowels = 0;
for (int idx=0; idx< str.length(); idx++){
if (isVowel(str[idx])) {
if (lastVowels > 0){
lastVowels++;
if (lastVowels >= LEN) {
lastResultMul = idx-1;
}
} else {
lastVowels = 1;
}
} else {
if (lastVowels < 0){
lastVowels--;
if (lastVowels <= -LEN) {
lastResultMul = idx-1;
}
} else {
lastVowels = -1;
}
}
result += lastResultMul;
}
printf("%lld", result);
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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | #include <iostream> #include <stdio.h> #include <string> int LEN = 3; int isVowel(char ch){ int c = toupper(ch); return (c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U'|| c == 'Y'); } using namespace std; int main(){ string str; getline(cin,str); long long lastResultMul = 0; long long result = 0; long long lastVowels = 0; for (int idx=0; idx< str.length(); idx++){ if (isVowel(str[idx])) { if (lastVowels > 0){ lastVowels++; if (lastVowels >= LEN) { lastResultMul = idx-1; } } else { lastVowels = 1; } } else { if (lastVowels < 0){ lastVowels--; if (lastVowels <= -LEN) { lastResultMul = idx-1; } } else { lastVowels = -1; } } result += lastResultMul; } printf("%lld", result); return 0; } |
English