#include <bits/stdc++.h> const char acgo[] = "acgo"; int main() { using namespace std; int n; cin >> n; string data; data.reserve(8 * n); cin >> data; int num1 = count(data.begin(), data.end(), '1'); // cout << num1 << endl; if (num1 < 3 * n || num1 > 6 * n) { cout << "NIE\n"; return 0; } int avg_low = num1 / n - 3; int num_hi = num1 % n; for (int i = 0; i < n - num_hi; ++i) cout << acgo[avg_low]; for (int i = 0; i < num_hi; ++i) cout << acgo[avg_low + 1]; cout << endl; 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> const char acgo[] = "acgo"; int main() { using namespace std; int n; cin >> n; string data; data.reserve(8 * n); cin >> data; int num1 = count(data.begin(), data.end(), '1'); // cout << num1 << endl; if (num1 < 3 * n || num1 > 6 * n) { cout << "NIE\n"; return 0; } int avg_low = num1 / n - 3; int num_hi = num1 % n; for (int i = 0; i < n - num_hi; ++i) cout << acgo[avg_low]; for (int i = 0; i < num_hi; ++i) cout << acgo[avg_low + 1]; cout << endl; return 0; } |