#include <iostream>
using namespace std;
int nr=1,zm,ost=1;
string a;
bool t[200],last;
long long w;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cin>>a;
t['a']=1;
t['e']=1;
t['i']=1;
t['o']=1;
t['u']=1;
t['y']=1;
last=t[a[0]];
for (int i=1; i<a.size(); i++)
{
if (t[a[i]]==last)
{
nr++;
if (nr==3)
{
w+=(long long)(i-ost)*(long long)(a.size()-i);
//w-=zm*(a.size()-i);
nr=2;
zm++;
ost=i;
//cout<<w<<" ";
}
}
else
{
nr=1;
last=t[a[i]];
}
}
cout<<w;
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 | #include <iostream> using namespace std; int nr=1,zm,ost=1; string a; bool t[200],last; long long w; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin>>a; t['a']=1; t['e']=1; t['i']=1; t['o']=1; t['u']=1; t['y']=1; last=t[a[0]]; for (int i=1; i<a.size(); i++) { if (t[a[i]]==last) { nr++; if (nr==3) { w+=(long long)(i-ost)*(long long)(a.size()-i); //w-=zm*(a.size()-i); nr=2; zm++; ost=i; //cout<<w<<" "; } } else { nr=1; last=t[a[i]]; } } cout<<w; return 0; } |
English