Submission #2380

#TimeUsernameProblemLanguageResultExecution timeMemory
2380crazysoldier생일수 I (GA4_birthday1)C++98
14 / 100
67 ms1376 KiB
#include <iostream>
#include <stdio.h>

using namespace std;
int main()
{
    long long n,three,five,eight,i,k,input;
    scanf("%lld",&n);
    for(k=1;k<=n;k++)
    {
        scanf("%lld",&input);
        if(!((input-1)*(input-2)*(input-4)*(input-7))) {printf("-1\n"); continue;}
        three=0,five=0,eight=0;
        if(input>120) {eight+=input/8-15; input %= 120;}
        if(input%3==0) three+=input/3;
        else if(input%3==1) {five+=2; three+=(input-10)/3;}
        else {five+=1; three+=(input-5)/3;}
        while(three>=5)
        {
            three-=5;
            five+=3;
        }
        while(five>=8)
        {
            five-=8;
            eight+=5;
        }
        while(three && five)
        {
            three--;
            five--;
            eight++;
        }
        for(i=1;i<=three;i++) printf("3");
        for(i=1;i<=five;i++) printf("5");
        for(i=1;i<=eight;i++) printf("8");
        printf("\n");
    }
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...