답안 #2336

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
2336 2013-07-21T03:26:20 Z pull601 생일수 I (GA4_birthday1) C
41 / 100
789 ms 4692 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",-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 Incorrect 0 ms 4692 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 4692 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 4692 KB Output is correct
2 Incorrect 0 ms 4692 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 695 ms 4692 KB Output is correct
2 Correct 694 ms 4692 KB Output is correct
3 Correct 736 ms 4692 KB Output is correct
4 Correct 645 ms 4692 KB Output is correct
5 Correct 710 ms 4692 KB Output is correct
6 Correct 695 ms 4692 KB Output is correct
7 Correct 743 ms 4692 KB Output is correct
8 Correct 747 ms 4692 KB Output is correct
9 Correct 749 ms 4692 KB Output is correct
10 Correct 723 ms 4692 KB Output is correct
11 Correct 698 ms 4692 KB Output is correct
12 Correct 709 ms 4692 KB Output is correct
13 Correct 713 ms 4692 KB Output is correct
14 Correct 778 ms 4692 KB Output is correct
15 Correct 694 ms 4692 KB Output is correct
16 Correct 702 ms 4692 KB Output is correct
17 Correct 678 ms 4692 KB Output is correct
18 Correct 688 ms 4692 KB Output is correct
19 Correct 789 ms 4692 KB Output is correct
20 Correct 673 ms 4692 KB Output is correct
21 Correct 709 ms 4692 KB Output is correct
22 Correct 692 ms 4692 KB Output is correct
23 Correct 675 ms 4692 KB Output is correct
24 Correct 679 ms 4692 KB Output is correct
25 Correct 687 ms 4692 KB Output is correct