답안 #3136

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
3136 2013-08-26T07:31:14 Z movie_jo 생일수 I (GA4_birthday1) C
100 / 100
132 ms 16712 KB
#include <stdio.h>

struct X {
	int three;
	int five;
	int eight;
	int sum;
} x[1000001];

int main(void)
{
	int T, n, i;

	x[3].three = 1;
	x[3].sum = 1;
	x[5].five = 1;
	x[5].sum = 1;
	x[6].three = 2;
	x[6].sum = 2;
	x[8].eight = 1;
	x[8].sum = 1;

	for(i = 9; i <= 1000000; i++)
	{
		if(x[i - 3].sum)
		{
			x[i] = x[i - 3];
			x[i].three++;
		}
		if(x[i - 5].sum && (x[i].sum == 0 || x[i - 5].sum < x[i].sum))
		{
			x[i] = x[i - 5];
			x[i].five++;
		}
		if(x[i - 8].sum && (x[i].sum == 0 || x[i - 8].sum < x[i].sum))
		{
			x[i] = x[i - 8];
			x[i].eight++;
		}
		x[i].sum++;
	}

	scanf("%d", &T);

	while(T--)
	{
		scanf("%d", &n);

		if(x[n].sum)
		{
			for(i = 0; i < x[n].three; i++)
				printf("3");
			for(i = 0; i < x[n].five; i++)
				printf("5");
			for(i = 0; i < x[n].eight; i++)
				printf("8");
		}
		else
			printf("-1");
		printf("\n");
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 16712 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 16712 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 16712 KB Output is correct
2 Correct 8 ms 16712 KB Output is correct
3 Correct 4 ms 16712 KB Output is correct
4 Correct 8 ms 16712 KB Output is correct
5 Correct 8 ms 16712 KB Output is correct
6 Correct 0 ms 16712 KB Output is correct
7 Correct 8 ms 16712 KB Output is correct
8 Correct 8 ms 16712 KB Output is correct
9 Correct 4 ms 16712 KB Output is correct
10 Correct 4 ms 16712 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 128 ms 16712 KB Output is correct
2 Correct 112 ms 16712 KB Output is correct
3 Correct 124 ms 16712 KB Output is correct
4 Correct 116 ms 16712 KB Output is correct
5 Correct 116 ms 16712 KB Output is correct
6 Correct 116 ms 16712 KB Output is correct
7 Correct 128 ms 16712 KB Output is correct
8 Correct 120 ms 16712 KB Output is correct
9 Correct 96 ms 16712 KB Output is correct
10 Correct 124 ms 16712 KB Output is correct
11 Correct 108 ms 16712 KB Output is correct
12 Correct 108 ms 16712 KB Output is correct
13 Correct 124 ms 16712 KB Output is correct
14 Correct 132 ms 16712 KB Output is correct
15 Correct 76 ms 16712 KB Output is correct
16 Correct 132 ms 16712 KB Output is correct
17 Correct 128 ms 16712 KB Output is correct
18 Correct 84 ms 16712 KB Output is correct
19 Correct 72 ms 16712 KB Output is correct
20 Correct 112 ms 16712 KB Output is correct
21 Correct 92 ms 16712 KB Output is correct
22 Correct 96 ms 16712 KB Output is correct
23 Correct 120 ms 16712 KB Output is correct
24 Correct 56 ms 16712 KB Output is correct
25 Correct 120 ms 16712 KB Output is correct