#include <bits/stdc++.h> #define maxn 1000009 using namespace std; string s; int tab[maxn]; long long wyn; int main() { cin>>s; int n=s.length(); for(int i=0; i<n; i++) { char a=s[i]; if(a=='a' || a=='e' || a=='i' || a=='o' || a=='u' || a=='y') { tab[i]=0; } else { tab[i]=1; } } int x=0; int x2=0; for(int i=0; i<n-2; i++) { //cout<<tab[i]<<" "; if(tab[i]+tab[i+1]+tab[i+2]==0 || tab[i]+tab[i+1]+tab[i+2]==3) { //cout<<i<<" "<<x<<endl; if(x2<i) { wyn+=(long long)i-x; wyn+=(long long)(i-x)*(long long)(n-i-3); } wyn+=(long long)n-i-3; wyn++; x=i+1; x2=i+2; //cout<<wyn<<endl; } } //cout<<endl; cout<<wyn; return 0; } //hpdodxjg
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 | #include <bits/stdc++.h> #define maxn 1000009 using namespace std; string s; int tab[maxn]; long long wyn; int main() { cin>>s; int n=s.length(); for(int i=0; i<n; i++) { char a=s[i]; if(a=='a' || a=='e' || a=='i' || a=='o' || a=='u' || a=='y') { tab[i]=0; } else { tab[i]=1; } } int x=0; int x2=0; for(int i=0; i<n-2; i++) { //cout<<tab[i]<<" "; if(tab[i]+tab[i+1]+tab[i+2]==0 || tab[i]+tab[i+1]+tab[i+2]==3) { //cout<<i<<" "<<x<<endl; if(x2<i) { wyn+=(long long)i-x; wyn+=(long long)(i-x)*(long long)(n-i-3); } wyn+=(long long)n-i-3; wyn++; x=i+1; x2=i+2; //cout<<wyn<<endl; } } //cout<<endl; cout<<wyn; return 0; } //hpdodxjg |