Submission #17522

# Submission time Handle Problem Language Result Execution time Memory
17522 2015-12-25T13:37:33 Z atomzeno 생일수 I (GA4_birthday1) C++
14 / 100
114 ms 4988 KB
#include<stdio.h>
#define MX 1000001
int A[MX],B[3]={3,5,8},a,num[3];
int main(){
    int i,j,n;
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    A[0]=0;
    for(i=1;i<MX;i++){A[i]=MX+1;}
    for(i=1;i<MX;i++){
        for(j=0;j<3;j++){
            if(i>=B[j]&&(A[i-B[j]]+1)<A[i]){
                A[i]=(A[i-B[j]]+1);
            }
        }
    }
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a);
        if(A[a]==MX+1){printf("-1\n");}
        else{
            for(j=0;j<3;j++){num[j]=0;}
            for(j=a;j!=0;){
                if(j>=8&&A[j-8]<MX){
                    num[2]++;
                    j-=8;
                }
                else if(j>=5&&A[j-5]<MX){
                    num[1]++;
                    j-=5;
                }
                else{
                    num[0]++;
                    j-=3;
                }
            }
            for(j=0;j<num[0];j++){printf("3");}
            for(j=0;j<num[1];j++){printf("5");}
            for(j=0;j<num[2];j++){printf("8");}
            printf("\n");
        }
    }
}
# Verdict Execution time Memory Grader output
1 Correct 7 ms 4988 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 4988 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 4988 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 114 ms 4988 KB Output isn't correct
2 Halted 0 ms 0 KB -