#include "iostream" #include "string" using namespace std; string s; int ok[1005], last; long long res; int main() { ios_base::sync_with_stdio(0); cin >> s; ok['a'] = 1; ok['e'] = 1; ok['y'] = 1; ok['u'] = 1; ok['i'] = 1; ok['o'] = 1; for (int i = 2; i < s.size(); i++) { if ((ok[s[i]] + ok[s[i-1]] + ok[s[i-2]]) % 3 == 0) { res += (i - 2 - last + 1) * (s.size() - i); last = i - 1; } } cout << res << "\n"; 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 "iostream" #include "string" using namespace std; string s; int ok[1005], last; long long res; int main() { ios_base::sync_with_stdio(0); cin >> s; ok['a'] = 1; ok['e'] = 1; ok['y'] = 1; ok['u'] = 1; ok['i'] = 1; ok['o'] = 1; for (int i = 2; i < s.size(); i++) { if ((ok[s[i]] + ok[s[i-1]] + ok[s[i-2]]) % 3 == 0) { res += (i - 2 - last + 1) * (s.size() - i); last = i - 1; } } cout << res << "\n"; return 0; } |