#include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int E[123]; for(int i = 0; i < 123; ++i) E[i] = 0; E[97] = 1; E[101] = 1; E[105] = 1; E[111] = 1; E[117] = 1; E[121] = 1; string s; cin >> s; long long res = 0; for(int i = 0, j = 1; i < s.size() - 2; ++i, ++j) { if(E[s[i]] == E[s[i + 1]] && E[s[i + 1]] == E[s[i + 2]]) { res += j * (s.size() - i - 2); j = 0; } } 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 <iostream> #include <vector> #include <algorithm> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int E[123]; for(int i = 0; i < 123; ++i) E[i] = 0; E[97] = 1; E[101] = 1; E[105] = 1; E[111] = 1; E[117] = 1; E[121] = 1; string s; cin >> s; long long res = 0; for(int i = 0, j = 1; i < s.size() - 2; ++i, ++j) { if(E[s[i]] == E[s[i + 1]] && E[s[i + 1]] == E[s[i + 2]]) { res += j * (s.size() - i - 2); j = 0; } } cout << res; return 0; } |