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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <bits/stdc++.h>
using namespace std;

//zmienne
int n;
string ciag;
const int MIN = 3;
const int MAX = 6;
int licz = 0;
string res = "";

//kontenerty
char odp[7] = {'0', '1', '2', 'a', 'c', 'g', 'o'};

//funkcje
//**********************************

//**********************************

int main()
{
  cin>> n >> ciag;

  for (int i = 0; i < 8*n; i++)
  {
    if (ciag[i] == '1')
      licz++;
  }

  int num = licz/n;
  if (num < MIN || num > MAX)
    cout<< "NIE";
  else
  {
    int add = licz % n;
    if (add > 0)
    {
      if (num + 1 > MAX)
        cout<< "NIE";
    }

    for (int i = 0; i < n; i++)
    {
      if (add > 0)
      {
        res += odp[num+1];
        add--;
      }
      else
      {
        res += odp[num];
      }
    }
  }

  cout<< res;

return 0;
}