#include <stdio.h>
int main()
{
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
int i, t, n, n5, n3, s5, n8;
scanf("%d", &t);
while(t>0)
{
t--;
n3=-1;
scanf("%d", &n);
if(n%8==0)
{
for(i=1;i<=n/8;i++) printf("8");
printf("\n");
continue;
}
n5=n/5;
for(i=n5;i>=0;i--)
{
s5=i*5;
if((n-s5)%3==0)
{
n3=(n-s5)/3;
n5=i;
break;
}
}
if(n3==(-1)) {printf("-1\n"); continue;}
if(n3>n5)
{
n8=n5;
n3=n3-n5;
n5=0;
}
else
{
n8=n3;
n5=n5-n3;
n3=0;
}
for(i=1;i<=n3;i++) printf("3");
for(i=1;i<=n5;i++) printf("5");
for(i=1;i<=n8;i++) printf("8");
printf("\n");
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
0 ms |
880 KB |
close (syscall #3) was called by the program (disallowed syscall) |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
0 ms |
880 KB |
close (syscall #3) was called by the program (disallowed syscall) |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
0 ms |
880 KB |
close (syscall #3) was called by the program (disallowed syscall) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
0 ms |
880 KB |
close (syscall #3) was called by the program (disallowed syscall) |
2 |
Halted |
0 ms |
0 KB |
- |