#include <iostream> #include <vector> #include <string> int main() { std::ios::sync_with_stdio(false); int n; std::cin >> n; std::string s; std::cin >> s; int k = 0; for (int i = 0; i < s.length(); ++i) { if (s[i] == '1') ++k; } if ((k < 3 * n) || (k > 6 * n)) { std::cout << "NIE"; return 0; } while (n > 0) { int chars = k / n; k -= chars; n--; if (chars == 3) std::cout << 'a'; else if (chars == 4) std::cout << 'c'; else if (chars == 5) std::cout << 'g'; else if (chars == 6) std::cout << 'o'; } 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 32 | #include <iostream> #include <vector> #include <string> int main() { std::ios::sync_with_stdio(false); int n; std::cin >> n; std::string s; std::cin >> s; int k = 0; for (int i = 0; i < s.length(); ++i) { if (s[i] == '1') ++k; } if ((k < 3 * n) || (k > 6 * n)) { std::cout << "NIE"; return 0; } while (n > 0) { int chars = k / n; k -= chars; n--; if (chars == 3) std::cout << 'a'; else if (chars == 4) std::cout << 'c'; else if (chars == 5) std::cout << 'g'; else if (chars == 6) std::cout << 'o'; } return 0; } |