#include <cstdio> int n; char s[4000003]; const char p[8] = {0, 0, 0, 'a', 'c', 'g', 'o', 0}; int main() { scanf("%d%s", &n, s); int ones = 0; for (int i = 0; i < 8 * n; i++) { if (s[i] == '1') ones++; } if (ones < 3 * n || ones > 6 * n) { printf("NIE\n"); return 0; } while (n) { int w = ones / n; ones -= w; n--; printf("%c", p[w]); } printf("\n"); 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 | #include <cstdio> int n; char s[4000003]; const char p[8] = {0, 0, 0, 'a', 'c', 'g', 'o', 0}; int main() { scanf("%d%s", &n, s); int ones = 0; for (int i = 0; i < 8 * n; i++) { if (s[i] == '1') ones++; } if (ones < 3 * n || ones > 6 * n) { printf("NIE\n"); return 0; } while (n) { int w = ones / n; ones -= w; n--; printf("%c", p[w]); } printf("\n"); return 0; } |