답안 #2239

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
2239 2013-07-20T14:53:53 Z kriii 생일수 I (GA4_birthday1) C++
100 / 100
69 ms 916 KB
#include <stdio.h>
#include <queue>

std::queue<int> Q;
long long V[60];

int main()
{
	int i,x,p;

	for (i=0;i<60;i++) V[i] = -1;
	Q.push(0); V[0] = 0;
	while (!Q.empty()){
		x = Q.front(); Q.pop();
		if (x > 50) break;
		if (V[x+3] == -1){
			Q.push(x+3); V[x+3] = V[x] * 10 + 3;
		}
		if (V[x+5] == -1){
			Q.push(x+5); V[x+5] = V[x] * 10 + 5;
		}
		if (V[x+8] == -1){
			Q.push(x+8); V[x+8] = V[x] * 10 + 8;
		}
	}

	int T;

	scanf ("%d",&T); while (T--){
		scanf ("%d",&x);
		if (x <= 50) printf ("%lld",V[x]);
		else{
			p = (x - 50 + 7) / 8;
			x -= p * 8;
			printf ("%lld",V[x]);
			for (i=0;i<p;i++) putchar('8');
		}
		printf ("\n");
	}

	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 916 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 916 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 916 KB Output is correct
2 Correct 0 ms 916 KB Output is correct
3 Correct 0 ms 916 KB Output is correct
4 Correct 0 ms 916 KB Output is correct
5 Correct 0 ms 916 KB Output is correct
6 Correct 0 ms 916 KB Output is correct
7 Correct 0 ms 916 KB Output is correct
8 Correct 0 ms 916 KB Output is correct
9 Correct 0 ms 916 KB Output is correct
10 Correct 0 ms 916 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 57 ms 916 KB Output is correct
2 Correct 51 ms 916 KB Output is correct
3 Correct 64 ms 916 KB Output is correct
4 Correct 55 ms 916 KB Output is correct
5 Correct 60 ms 916 KB Output is correct
6 Correct 66 ms 916 KB Output is correct
7 Correct 57 ms 916 KB Output is correct
8 Correct 69 ms 916 KB Output is correct
9 Correct 65 ms 916 KB Output is correct
10 Correct 65 ms 916 KB Output is correct
11 Correct 65 ms 916 KB Output is correct
12 Correct 58 ms 916 KB Output is correct
13 Correct 66 ms 916 KB Output is correct
14 Correct 65 ms 916 KB Output is correct
15 Correct 56 ms 916 KB Output is correct
16 Correct 62 ms 916 KB Output is correct
17 Correct 60 ms 916 KB Output is correct
18 Correct 52 ms 916 KB Output is correct
19 Correct 68 ms 916 KB Output is correct
20 Correct 56 ms 916 KB Output is correct
21 Correct 54 ms 916 KB Output is correct
22 Correct 52 ms 916 KB Output is correct
23 Correct 59 ms 916 KB Output is correct
24 Correct 53 ms 916 KB Output is correct
25 Correct 60 ms 916 KB Output is correct