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
#include<bits/stdc++.h>
using namespace std;

int n,sum = 0;

string s;

char tab[7] = {'0','0','0','a','c','g','o'};

int main()
{
    cin>>n>>s;
    n = s.size() / 8;
    for(int i = 0;i < s.size(); i++)
        if(s[i] == '1')
            sum++;
    int x = sum / n,r = sum % n;
   // cout<<sum<<' '<<x<<'\n';
    if(sum < 3 * n || sum > 6 * n)
    {
        cout<<"NIE\n";
        return 0;
    }
    for(int i = 0;i < r; i++)
        cout<<tab[x + 1];
    for(int i = 0;i < n - r; i++)
        cout<<tab[x];
    return 0;
}