#include<iostream> using namespace std; int main () { string a; long long s=0; long long pop=0; cin>>a; int sp=0; int sa=0; for (int i=0;i<a.size();i++) { if (a[i]=='a' || a[i]=='e' || a[i]=='i' || a[i]=='o' || a[i]=='u' || a[i]=='y') { sa=sa+1; sp=0; if (sa==4) { sa=3; } } else { sp=sp+1; sa=0; if (sp==4) { sp=3; } } if (sp==3 || sa==3) { s=s+1+((i-pop)-2)+(a.size()-i-1)+(((i-pop)-2)*(a.size()-i-1)); pop=i-1; } } cout<<s; }
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 | #include<iostream> using namespace std; int main () { string a; long long s=0; long long pop=0; cin>>a; int sp=0; int sa=0; for (int i=0;i<a.size();i++) { if (a[i]=='a' || a[i]=='e' || a[i]=='i' || a[i]=='o' || a[i]=='u' || a[i]=='y') { sa=sa+1; sp=0; if (sa==4) { sa=3; } } else { sp=sp+1; sa=0; if (sp==4) { sp=3; } } if (sp==3 || sa==3) { s=s+1+((i-pop)-2)+(a.size()-i-1)+(((i-pop)-2)*(a.size()-i-1)); pop=i-1; } } cout<<s; } |