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 <cstdio>
#include <cstdlib>

int main()
{
char *str,c[] = "acgo";
int K,k,x,y;
	scanf("%d",&K);
	str = (char*) malloc((K*8+1)*sizeof(char));
	scanf("%s",str);

	x = 0;
	for (k = 0; k < 8*K; k++)
	{
		if (str[k] == '1') x++;
	}
	k = K;
	if (x >= 3*K && x <= 6*K)
	{
		while (x > 0)
		{
			y = (int) x / k;
			y += (y*k < x)?1:0;
//printf("x=%d k=%d y=%d o=%c\n",x,k,y,c[y-3]);
			printf("%c",c[y-3]);
			x -= y;
			k--;
		}
		printf("\n");
	}
	else printf("NIE");
	
	free(str);
	
	return 0;
}