#include<bits/stdc++.h> using namespace std; #define int long long string s; bool foo( int i ) { return s[i]=='a' || s[i]=='e' || s[i]=='i' || s[i]=='o' || s[i]=='u' || s[i]=='y'; //A, E, I, O, U, Y } int32_t main() { ios_base::sync_with_stdio( 0 ); cin.tie( 0 ); cin >> s; int pop = -1, res = 0; for( int i=2; i<s.size(); i++ ) { if( foo(i) == foo(i-1) && foo(i) == foo(i-2) ) { pop = i-2; } res += pop+1; } cout << res; 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 | #include<bits/stdc++.h> using namespace std; #define int long long string s; bool foo( int i ) { return s[i]=='a' || s[i]=='e' || s[i]=='i' || s[i]=='o' || s[i]=='u' || s[i]=='y'; //A, E, I, O, U, Y } int32_t main() { ios_base::sync_with_stdio( 0 ); cin.tie( 0 ); cin >> s; int pop = -1, res = 0; for( int i=2; i<s.size(); i++ ) { if( foo(i) == foo(i-1) && foo(i) == foo(i-2) ) { pop = i-2; } res += pop+1; } cout << res; return 0; } |