/* 2021 * Maciej Szeptuch */ #include <cstdio> const char letter[4] = { 'a', 'c', 'g', 'o', }; int ones; int letters; char bits[1048576]; int main(void) { scanf("%d %s", &letters, bits); for(int b = 0; b < 8 * letters; ++b) ones += bits[b] == '1'; ones -= 2 * letters; if(letters > ones || ones > 4 * letters) { puts("NIE"); return 0; } while(ones > 0) { putchar(letter[ones / letters - 1]); ones -= ones / letters; --letters; } puts(""); 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 33 34 35 36 37 38 39 | /* 2021 * Maciej Szeptuch */ #include <cstdio> const char letter[4] = { 'a', 'c', 'g', 'o', }; int ones; int letters; char bits[1048576]; int main(void) { scanf("%d %s", &letters, bits); for(int b = 0; b < 8 * letters; ++b) ones += bits[b] == '1'; ones -= 2 * letters; if(letters > ones || ones > 4 * letters) { puts("NIE"); return 0; } while(ones > 0) { putchar(letter[ones / letters - 1]); ones -= ones / letters; --letters; } puts(""); return 0; } |