#include <bits/stdc++.h> using namespace std; int main() { //freopen("in/1.in", "r", stdin); ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; string s; cin >> s; int ones = 0; for (auto& c : s) { if (c == '1') { ones++; } } map<int, char> letter = {{3, 'a'}, {4, 'c'}, {5, 'g'}, {6, 'o'}}; int d = ones / n; if ((d < 3) || (d > 6) || ((d == 6) && ((ones % n) != 0))) { cout << "NIE"; } else { while (n > 0) { d = ones / n; cout << letter[d]; ones -= d; n -= 1; } } }
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 32 33 34 | #include <bits/stdc++.h> using namespace std; int main() { //freopen("in/1.in", "r", stdin); ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; string s; cin >> s; int ones = 0; for (auto& c : s) { if (c == '1') { ones++; } } map<int, char> letter = {{3, 'a'}, {4, 'c'}, {5, 'g'}, {6, 'o'}}; int d = ones / n; if ((d < 3) || (d > 6) || ((d == 6) && ((ones % n) != 0))) { cout << "NIE"; } else { while (n > 0) { d = ones / n; cout << letter[d]; ones -= d; n -= 1; } } } |