#include<bits/stdc++.h> #define luk(n,m) for(int i=n; i<m; ++i) #define maxn 2000010 #define pb(n) push_back(n) #define mp make_pair #define inf 1000000000 #define mod 1000000007 #define ll long long #define ff first.first #define fs first.second char tab[maxn]; ll wynik; using namespace std; int ile(int x) { if(tab[x]=='a'||tab[x]=='i'||tab[x]=='u'||tab[x]=='o'||tab[x]=='e'||tab[x]=='y') return 1; else return 0; } bool spraw(int x) { if(ile(x)==ile(x-1)&&ile(x-1)==ile(x-2)) return true; else return false; } int main() { scanf("%s", tab); int ost=0; int n=strlen(tab); luk(0,n) { if(i-ost>=2&&spraw(i)) { ll a=i-2-ost+1; ll b=n-1-i+1; wynik+=a*b; ost=i-1; } } printf("%lld", wynik); }
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 | #include<bits/stdc++.h> #define luk(n,m) for(int i=n; i<m; ++i) #define maxn 2000010 #define pb(n) push_back(n) #define mp make_pair #define inf 1000000000 #define mod 1000000007 #define ll long long #define ff first.first #define fs first.second char tab[maxn]; ll wynik; using namespace std; int ile(int x) { if(tab[x]=='a'||tab[x]=='i'||tab[x]=='u'||tab[x]=='o'||tab[x]=='e'||tab[x]=='y') return 1; else return 0; } bool spraw(int x) { if(ile(x)==ile(x-1)&&ile(x-1)==ile(x-2)) return true; else return false; } int main() { scanf("%s", tab); int ost=0; int n=strlen(tab); luk(0,n) { if(i-ost>=2&&spraw(i)) { ll a=i-2-ost+1; ll b=n-1-i+1; wynik+=a*b; ost=i-1; } } printf("%lld", wynik); } |