#include<stdio.h>
int main()
{
int i,j,k,t,n,l,s,x=21000000,y=21000000,z=21000000;
scanf("%d",&t);
for(l=1;l<=t;l++){
x=0;
y=0;
z=0;
scanf("%d",&n);
for(i=0;i<=n/8;i++){
for(j=0;j<=4;j++){
k=i*8+j*3;
if(k>n) continue;
k=(n-k)/5;
if(i*8+j*3+k*5!=n) continue;
if(i+j+k<x+y+z || (i+j+k==x+y+z && j>y) || (i+j+k==x+y+z && j==y && k>z) || (x==0 && y==0 && z==0)){
x=i;
y=j;
z=k;
}
}
}
if(x==0 && y==0 && z==0) printf("-1\n");
else{
for(i=1;i<=y;i++) printf("3");
for(i=1;i<=z;i++) printf("5");
for(i=1;i<=x;i++) printf("8");
printf("\n");
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1088 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1088 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1088 KB |
Output is correct |
2 |
Correct |
0 ms |
1088 KB |
Output is correct |
3 |
Correct |
0 ms |
1088 KB |
Output is correct |
4 |
Correct |
0 ms |
1088 KB |
Output is correct |
5 |
Correct |
0 ms |
1088 KB |
Output is correct |
6 |
Correct |
0 ms |
1088 KB |
Output is correct |
7 |
Correct |
0 ms |
1088 KB |
Output is correct |
8 |
Correct |
0 ms |
1088 KB |
Output is correct |
9 |
Correct |
0 ms |
1088 KB |
Output is correct |
10 |
Correct |
0 ms |
1088 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
180 ms |
1088 KB |
Output is correct |
2 |
Correct |
156 ms |
1088 KB |
Output is correct |
3 |
Correct |
180 ms |
1088 KB |
Output is correct |
4 |
Correct |
156 ms |
1088 KB |
Output is correct |
5 |
Correct |
160 ms |
1088 KB |
Output is correct |
6 |
Correct |
184 ms |
1088 KB |
Output is correct |
7 |
Correct |
164 ms |
1088 KB |
Output is correct |
8 |
Correct |
164 ms |
1088 KB |
Output is correct |
9 |
Correct |
188 ms |
1088 KB |
Output is correct |
10 |
Correct |
160 ms |
1088 KB |
Output is correct |
11 |
Correct |
160 ms |
1088 KB |
Output is correct |
12 |
Correct |
160 ms |
1088 KB |
Output is correct |
13 |
Correct |
176 ms |
1088 KB |
Output is correct |
14 |
Correct |
180 ms |
1088 KB |
Output is correct |
15 |
Correct |
156 ms |
1088 KB |
Output is correct |
16 |
Correct |
168 ms |
1088 KB |
Output is correct |
17 |
Correct |
168 ms |
1088 KB |
Output is correct |
18 |
Correct |
148 ms |
1088 KB |
Output is correct |
19 |
Correct |
160 ms |
1088 KB |
Output is correct |
20 |
Correct |
152 ms |
1088 KB |
Output is correct |
21 |
Correct |
156 ms |
1088 KB |
Output is correct |
22 |
Correct |
176 ms |
1088 KB |
Output is correct |
23 |
Correct |
172 ms |
1088 KB |
Output is correct |
24 |
Correct |
172 ms |
1088 KB |
Output is correct |
25 |
Correct |
160 ms |
1088 KB |
Output is correct |