#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 |
1 |
Correct |
0 ms |
1376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
1376 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
1376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
67 ms |
1376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |