#include<cstdio> #include<algorithm> #include<string> #include<iostream> using namespace std; string s; bool samo(int a){ char ch = s[a]; if(ch == 'a' || ch == 'e' || ch =='y' || ch == 'u' || ch=='o' || ch=='i'){ return true; } return false; } bool spr(int a){ if(samo(a) == samo(a-1)&& samo(a) == samo(a-2)){ return true; } return false; } int main(void){ cin.tie(); ios_base::sync_with_stdio(0); cin >> s; long long ost = -1; long long odp = 0; for(int i = 2; i<s.size();i++){ if(spr(i)){ ost = i-2; } if(ost > -1){ odp += ost+1; } } printf("%lld",odp); 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 | #include<cstdio> #include<algorithm> #include<string> #include<iostream> using namespace std; string s; bool samo(int a){ char ch = s[a]; if(ch == 'a' || ch == 'e' || ch =='y' || ch == 'u' || ch=='o' || ch=='i'){ return true; } return false; } bool spr(int a){ if(samo(a) == samo(a-1)&& samo(a) == samo(a-2)){ return true; } return false; } int main(void){ cin.tie(); ios_base::sync_with_stdio(0); cin >> s; long long ost = -1; long long odp = 0; for(int i = 2; i<s.size();i++){ if(spr(i)){ ost = i-2; } if(ost > -1){ odp += ost+1; } } printf("%lld",odp); return 0; } |