This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |