#include <bits/stdc++.h> using namespace std; const char* SIGMA = "---acgo"; int main() { ios_base::sync_with_stdio(false); int n; cin >> n; string s; cin >> s; int m = 0; for (char c : s) if (c == '1') ++m; if (3 * n <= m && m <= 6 * n) { int k = m / n; if (k == 6) k = 5; string a = string(m - k * n, SIGMA[k + 1]); string b = string(n - a.length(), SIGMA[k]); cout << a << b << endl; } else { cout << "NIE" << endl; } }
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 | #include <bits/stdc++.h> using namespace std; const char* SIGMA = "---acgo"; int main() { ios_base::sync_with_stdio(false); int n; cin >> n; string s; cin >> s; int m = 0; for (char c : s) if (c == '1') ++m; if (3 * n <= m && m <= 6 * n) { int k = m / n; if (k == 6) k = 5; string a = string(m - k * n, SIGMA[k + 1]); string b = string(n - a.length(), SIGMA[k]); cout << a << b << endl; } else { cout << "NIE" << endl; } } |