#include <bits/stdc++.h> long long samo = 0; long long spol = 0; long long buf = 0; using namespace std; int main() { ios_base::sync_with_stdio(false); string s; cin >> s; long long n = s.size(); long long res = (n-1)*(n-2)/2; for (size_t i = 0; i < s.length(); i++) { char c = s[i]; if(c=='a' || c=='e' || c=='u' || c=='i' || c=='o' || c=='y') { samo += 1; spol = 0; } else { spol += 1; samo = 0; } buf += 1; if(spol > 3 || samo > 3) { buf = 2; } if(spol == 3 || samo == 3) { res -= (buf-2)*(buf-3)/2; buf = 2; } } res -= (buf-1)*(buf-2)/2; cout << res << '\n'; }
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 | #include <bits/stdc++.h> long long samo = 0; long long spol = 0; long long buf = 0; using namespace std; int main() { ios_base::sync_with_stdio(false); string s; cin >> s; long long n = s.size(); long long res = (n-1)*(n-2)/2; for (size_t i = 0; i < s.length(); i++) { char c = s[i]; if(c=='a' || c=='e' || c=='u' || c=='i' || c=='o' || c=='y') { samo += 1; spol = 0; } else { spol += 1; samo = 0; } buf += 1; if(spol > 3 || samo > 3) { buf = 2; } if(spol == 3 || samo == 3) { res -= (buf-2)*(buf-3)/2; buf = 2; } } res -= (buf-1)*(buf-2)/2; cout << res << '\n'; } |