Submission #5758

# Submission time Handle Problem Language Result Execution time Memory
5758 2014-05-16T12:31:59 Z baneling100 생일수 I (GA4_birthday1) C++
14 / 100
68 ms 1088 KB
#include <stdio.h>

int T, N, num3, num5, num8, rest;

void input(void)
{
    scanf("%d",&N);
    num3=num5=num8=rest=0;
}

void output(void)
{
    int i;

    for(i=1 ; i<=num3 ; i++)
        printf("3");
    for(i=1 ; i<=num5 ; i++)
        printf("5");
    for(i=1 ; i<=num8 ; i++)
        printf("8");
    printf("\n");
}

void process(void)
{
    num3=N/3;
    rest=N%3;
    while(rest>0 && num3>0)
    {
        num3--;
        rest+=3;
        num5+=rest/5;
        rest%=5;
    }
    if(rest)
        printf("-1\n");
    else
    {
        if(num3<num5)
        {
            num8=num3;
            num5-=num3;
            num3=0;
            num8+=num5/8*5;
            num5%=8;
        }
        else
        {
            num8=num5;
            num3-=num5;
            num5=0;
            num8+=num3/8*3;
            num3%=8;
            num5+=num3/5*3;
            num3%=5;
        }
        output();
    }
}

int main(void)
{
    int i;

    scanf("%d",&T);
    for(i=1 ; i<=T ; i++)
    {
        input();
        process();
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1088 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 1088 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 1088 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 68 ms 1088 KB Output isn't correct
2 Halted 0 ms 0 KB -