답안 #2384

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
2384 2013-07-21T04:43:32 Z ldj5098 생일수 I (GA4_birthday1) C++
100 / 100
771 ms 4792 KB
#include <stdio.h>

#include <stdlib.h>

int d[1000001],f[9];

int main()

{

    int n,m,i,j,kk,t=0,tt=0;

    d[3]=1; d[0]=1; d[5]=1; d[8]=1;

    scanf("%d",&n);

    for(i=1;i<=n;i++){

        scanf("%d",&m);

        kk=m;

        for(j=1;j<=m;j++){

            if(d[j-3]==1) d[j]=1;

            else if(d[j-5]==1) d[j]=1;

            else if(d[j-8]==1) d[j]=1;

        }

        if(d[m]==0){printf("%d\n",-1); continue;}

        while(1){

            if(d[kk-8]==1){f[8]+=1; kk=kk-8; }

            else if(d[kk-5]==1){ f[5]+=1; kk=kk-5;}

            else if(d[kk-3]==1){f[3]+=1; kk=kk-3;}

            if(kk==0) break;

        }

        t=f[3]/4;

        if(t>0&&f[8]>0){ f[3]=f[3]-t*4;f[8]=f[8]-t; f[5]=f[5]+t*4;}

        for(j=1;j<=f[3];j++)printf("%d",3);

        for(j=1;j<=f[5];j++)printf("%d",5);

        for(j=1;j<=f[8];j++)printf("%d",8);

        printf("\n");

        f[3]=0; f[8]=0;f[5]=0;

    }

    return 0;

}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 4792 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 4792 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 4792 KB Output is correct
2 Correct 0 ms 4792 KB Output is correct
3 Correct 0 ms 4792 KB Output is correct
4 Correct 0 ms 4792 KB Output is correct
5 Correct 0 ms 4792 KB Output is correct
6 Correct 0 ms 4792 KB Output is correct
7 Correct 0 ms 4792 KB Output is correct
8 Correct 0 ms 4792 KB Output is correct
9 Correct 0 ms 4792 KB Output is correct
10 Correct 0 ms 4792 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 694 ms 4792 KB Output is correct
2 Correct 665 ms 4792 KB Output is correct
3 Correct 740 ms 4792 KB Output is correct
4 Correct 635 ms 4792 KB Output is correct
5 Correct 704 ms 4792 KB Output is correct
6 Correct 683 ms 4792 KB Output is correct
7 Correct 729 ms 4792 KB Output is correct
8 Correct 759 ms 4792 KB Output is correct
9 Correct 741 ms 4792 KB Output is correct
10 Correct 725 ms 4792 KB Output is correct
11 Correct 675 ms 4792 KB Output is correct
12 Correct 688 ms 4792 KB Output is correct
13 Correct 715 ms 4792 KB Output is correct
14 Correct 761 ms 4792 KB Output is correct
15 Correct 681 ms 4792 KB Output is correct
16 Correct 693 ms 4792 KB Output is correct
17 Correct 665 ms 4792 KB Output is correct
18 Correct 660 ms 4792 KB Output is correct
19 Correct 771 ms 4792 KB Output is correct
20 Correct 659 ms 4792 KB Output is correct
21 Correct 693 ms 4792 KB Output is correct
22 Correct 686 ms 4792 KB Output is correct
23 Correct 659 ms 4792 KB Output is correct
24 Correct 666 ms 4792 KB Output is correct
25 Correct 672 ms 4792 KB Output is correct