#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
string x;
long long wynik = 0;
int last_wsk = -1;
bool IfVowel(char c){
if(c == 'a' or c == 'e' or c == 'i' or c == 'o' or c == 'u' or c == 'y') return true;
else return false;
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> x;
if(x.size() < 3){
cout << 0;
return 0;
}
for(int i = 0; i < x.size() - 2; i++){
if((IfVowel(x[i]) and IfVowel(x[i+1]) and IfVowel(x[i+2])) or (!IfVowel(x[i]) and !IfVowel(x[i+1]) and !IfVowel(x[i+2]))){
wynik += ((i+1) * (x.size() - i - 2));
if(last_wsk != -1) wynik -= ((last_wsk + 1) * (x.size() - i - 2));
last_wsk = i;
}
}
cout << wynik;
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 | #include<iostream> #include<string> #include<algorithm> using namespace std; string x; long long wynik = 0; int last_wsk = -1; bool IfVowel(char c){ if(c == 'a' or c == 'e' or c == 'i' or c == 'o' or c == 'u' or c == 'y') return true; else return false; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> x; if(x.size() < 3){ cout << 0; return 0; } for(int i = 0; i < x.size() - 2; i++){ if((IfVowel(x[i]) and IfVowel(x[i+1]) and IfVowel(x[i+2])) or (!IfVowel(x[i]) and !IfVowel(x[i+1]) and !IfVowel(x[i+2]))){ wynik += ((i+1) * (x.size() - i - 2)); if(last_wsk != -1) wynik -= ((last_wsk + 1) * (x.size() - i - 2)); last_wsk = i; } } cout << wynik; return 0; } |
English