Submission #5760

# Submission time Handle Problem Language Result Execution time Memory
5760 2014-05-16T12:48:17 Z baneling100 생일수 I (GA4_birthday1) C++
0 / 100
72 ms 16712 KB
#include <stdio.h>
#define inf 0x7fffffff

int T, N[101], D[1000001], Limit, three[1000001], five[1000001], eight[1000001];

void input(void)
{
    int i;

    scanf("%d",&T);
    for(i=1 ; i<=T ; i++)
    {
        scanf("%d",&N[i]);
        if(Limit<N[i])
            Limit=N[i];
    }
}

void process(void)
{
    int i, mmin, v;

    D[1]=D[2]=D[4]=D[7]=inf;
    D[3]=D[5]=D[6]=1;
    three[3]=five[5]=1;
    three[6]=2;
    for(i=8 ; i<=Limit ; i++)
    {
        mmin=D[i-3];
        v=3;
        if(mmin>D[i-5])
        {
            v=5;
            mmin=D[i-5];
        }
        if(mmin>D[i-8])
        {
            v=8;
            mmin=D[i-8];
        }
        if(mmin==inf)
            D[i]=inf;
        else
        {
            D[i]=mmin+1;
            if(v==3)
            {
                three[i]=three[i-3]+1;
                five[i]=five[i-3];
                eight[i]=eight[i-3];
            }
            else if(v==5)
            {
                three[i]=three[i-5];
                five[i]=five[i-5]+1;
                eight[i]=eight[i-5];
            }
            else
            {
                three[i]=three[i-8];
                five[i]=five[i-8];
                eight[i]=eight[i-8]+1;
            }
        }
    }
}

void output(void)
{
    int i, j;

    for(i=1 ; i<=T ; i++)
    {
        if(D[N[i]]==inf)
            printf("-1");
        else
        {
            for(j=1 ; j<=three[N[i]] ; j++)
                printf("3");
            for(j=1 ; j<=five[N[i]] ; j++)
                printf("5");
            for(j=1 ; j<=eight[N[i]] ; j++)
                printf("8");
            printf("\n");
        }
    }
}

int main(void)
{
    input();
    process();
    output();

    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 16712 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 16712 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 16712 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 72 ms 16712 KB Output isn't correct
2 Halted 0 ms 0 KB -