#include <iostream> #include <string> using namespace std; int b, odp, p, l; string s; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> s; for (int i = 0; i < s.size(); i++) { if (s[i] == 97 || s[i] == 101 || s[i] == 105 || s[i] == 111 || s[i] == 117 || s[i] == 121) { s[i] = 'a'; } else { s[i] = 'b'; } } for (int i = 0; i < s.size() - 2; i++) { if (s[i] == s[i + 1] && s[i] == s[i + 2]) { p = i - b; // ile literek po prawej do bariery l = s.size() - i - 3; // ile literek po lewej odp += 1 + p + l + p * l; b = i + 1; } } cout << 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 | #include <iostream> #include <string> using namespace std; int b, odp, p, l; string s; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> s; for (int i = 0; i < s.size(); i++) { if (s[i] == 97 || s[i] == 101 || s[i] == 105 || s[i] == 111 || s[i] == 117 || s[i] == 121) { s[i] = 'a'; } else { s[i] = 'b'; } } for (int i = 0; i < s.size() - 2; i++) { if (s[i] == s[i + 1] && s[i] == s[i + 2]) { p = i - b; // ile literek po prawej do bariery l = s.size() - i - 3; // ile literek po lewej odp += 1 + p + l + p * l; b = i + 1; } } cout << odp; return 0; } |