#include<iostream>
#include<string>
using namespace std;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int tab[6]={97,101,105,111,117,121};
string ciag;
cin>>ciag;
bool pom[3];
bool pom1=false,pom2=false;
int N=ciag.size();
int licz=0;
for(int i=0;i<N-2;i++)
{
for(int k=0;k<3;k++) pom[k]=false;
for(int j=0;j<6;j++)
{
if(int(ciag[i])==tab[j]) pom[0]=true;
if(int(ciag[i+1])==tab[j])pom[1]=true;
if(int(ciag[i+2])==tab[j])pom[2]=true;
}
if(pom[0]==pom[1] && pom[1]==pom[2])
{
if(i==0)
{
pom1=true;
}else if(i==N-3)
{
pom2=true;
}else;
licz++;
if(i!=0)
{
licz+=i;
licz+=(N-i-3);
licz+=i*(N-i-3);
}else licz+=(N-3);
}
}
if(pom1 && pom2)
{
licz--;
}
cout<<licz<<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 | #include<iostream> #include<string> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int tab[6]={97,101,105,111,117,121}; string ciag; cin>>ciag; bool pom[3]; bool pom1=false,pom2=false; int N=ciag.size(); int licz=0; for(int i=0;i<N-2;i++) { for(int k=0;k<3;k++) pom[k]=false; for(int j=0;j<6;j++) { if(int(ciag[i])==tab[j]) pom[0]=true; if(int(ciag[i+1])==tab[j])pom[1]=true; if(int(ciag[i+2])==tab[j])pom[2]=true; } if(pom[0]==pom[1] && pom[1]==pom[2]) { if(i==0) { pom1=true; }else if(i==N-3) { pom2=true; }else; licz++; if(i!=0) { licz+=i; licz+=(N-i-3); licz+=i*(N-i-3); }else licz+=(N-3); } } if(pom1 && pom2) { licz--; } cout<<licz<<endl; return 0; } |
English