#include <iostream>
using namespace std;
typedef long long ll;
ll f(char c){
return c=='a' ||
c=='e' ||
c=='i' ||
c=='o' ||
c=='u' ||
c=='y';
}
ll g(ll n){
return n*(n+1)/2;
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(NULL);
string s;
cin>>s;
ll n=s.size(), len=2;
if(n<3){
cout<<0;
return 0;
}
bool is_all_same=true;
for(int i=0;i<n-1;i++)
if(f(s[i])!=f(s[i+1]))
is_all_same=false;
ll suma=f(s[0])+f(s[1])+f(s[2]), wynik=g(n);
bool is_first=true;
if(suma==0 || suma==3) {
wynik-=g(2);
is_first=false;
}
else len=3;
for(ll i=3;i<n;i++){
suma-=f(s[i-3]);
suma+=f(s[ i ]);
if(suma==0 || suma==3){
wynik-=g(len);
if(!is_first)wynik++;
is_first=false;
len=2;
}else{
len++;
}
}
wynik-=g(len);
wynik++;
if(is_first) wynik=0;
cout<<wynik;
}
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 52 53 54 55 | #include <iostream> using namespace std; typedef long long ll; ll f(char c){ return c=='a' || c=='e' || c=='i' || c=='o' || c=='u' || c=='y'; } ll g(ll n){ return n*(n+1)/2; } int main(){ ios_base::sync_with_stdio(0); cin.tie(NULL); string s; cin>>s; ll n=s.size(), len=2; if(n<3){ cout<<0; return 0; } bool is_all_same=true; for(int i=0;i<n-1;i++) if(f(s[i])!=f(s[i+1])) is_all_same=false; ll suma=f(s[0])+f(s[1])+f(s[2]), wynik=g(n); bool is_first=true; if(suma==0 || suma==3) { wynik-=g(2); is_first=false; } else len=3; for(ll i=3;i<n;i++){ suma-=f(s[i-3]); suma+=f(s[ i ]); if(suma==0 || suma==3){ wynik-=g(len); if(!is_first)wynik++; is_first=false; len=2; }else{ len++; } } wynik-=g(len); wynik++; if(is_first) wynik=0; cout<<wynik; } |
English