#include <iostream>
using namespace std;
bool czy_sam(char A){
if(A=='a'||A=='e'||A=='i'||A=='o'||A=='u'||A=='y')
return true;
return false;
}
int main(){
ios_base::sync_with_stdio(0);
string s;
cin>>s;
int n=s.length();
int ileok=0;
int j=0;
for(int i=0;i<n;i++){//spolgloski
if(czy_sam(s[i])==false){
j++;
}
else
j=0;
if(j>=3)
ileok++;
}
j=0;
for(int i=0;i<n;i++){//samogloski
if(czy_sam(s[i])==true){
j++;
}
else
j=0;
if(j>=3)
ileok++;
}
long long wyn=n*(n+1);
wyn/=2;
wyn-=n;
wyn-=n-1;
int od=n-2;
//cout<<"ILE OK:"<<ileok<<endl;
//cout<<"OD:"<<od<<endl;
//cout<<"WYN:"<<wyn<<endl;
j=ileok;
bool spr=true;
for(int i=od;i>=1;i--){
//cout<<"J:"<<j<<" z I:"<<i<<endl;
wyn-=i-j;
if(((j==i-1)||(j==i))&&spr==true){
//cout<<"ODWRACAM"<<endl;
spr=false;
if(j==i)
j--;
j++;
}
if(spr)
j++;
else
j--;
}
cout<<wyn<<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 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 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | #include <iostream> using namespace std; bool czy_sam(char A){ if(A=='a'||A=='e'||A=='i'||A=='o'||A=='u'||A=='y') return true; return false; } int main(){ ios_base::sync_with_stdio(0); string s; cin>>s; int n=s.length(); int ileok=0; int j=0; for(int i=0;i<n;i++){//spolgloski if(czy_sam(s[i])==false){ j++; } else j=0; if(j>=3) ileok++; } j=0; for(int i=0;i<n;i++){//samogloski if(czy_sam(s[i])==true){ j++; } else j=0; if(j>=3) ileok++; } long long wyn=n*(n+1); wyn/=2; wyn-=n; wyn-=n-1; int od=n-2; //cout<<"ILE OK:"<<ileok<<endl; //cout<<"OD:"<<od<<endl; //cout<<"WYN:"<<wyn<<endl; j=ileok; bool spr=true; for(int i=od;i>=1;i--){ //cout<<"J:"<<j<<" z I:"<<i<<endl; wyn-=i-j; if(((j==i-1)||(j==i))&&spr==true){ //cout<<"ODWRACAM"<<endl; spr=false; if(j==i) j--; j++; } if(spr) j++; else j--; } cout<<wyn<<endl; return 0; } |
English