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
#include <iostream>

using namespace std;

const int SIZE = 800001;
int n, t, o;
char c;
char arr[SIZE];

int main() {
    cin >> n;
    for(int i = 0; i < n * 8; i++) {
        scanf(" %c", &c);
        o += c - 48;
    }

    t = n;
    while(t) {
        switch(o / t) {
            case 3: arr[t] = 'a'; break;
            case 4: arr[t] = 'c'; break;
            case 5: arr[t] = 'g'; break;
            case 6: arr[t] = 'o'; break;
            default:
                cout << "NIE\n";
                return 0;
            break;

        }
        o -= o / t;
        t--;
    }

    for(int i = 1; i <= n; i++)
        cout << arr[i];
}