#include<stdio.h>
int d[101], t3[101], t5[101], kk[101], f3[1000001], f5[1000001];
int main()
{
int n, i, a, j, maxim=0, mini, k, tt;
scanf("%d", &n);
for(i=1;i<=n;i++){
scanf("%d", &d[i]);
if(maxim<d[i]) maxim=d[i];
}
for(i=3;i<=maxim;i+=3)f3[i]=i/3;
for(i=5;i<=maxim;i+=5)f5[i]=i/5;
for(i=1;i<=n;i++){
mini=9999999;
k=0;
tt=d[i];
while(1){
if(tt<0)break;
if(tt==0){
t3[i]=0;
t5[i]=0;
kk[i]=k;
}
if(f3[tt]!=0 && f3[tt]+k <= mini){
mini=f3[tt]+k;
t3[i]=f3[tt];
t5[i]=0;
kk[i]=k;
}
if(f5[tt]!=0 && f5[tt]+k <= mini){
mini=f5[tt]+k;
t5[i]=f5[tt];
t3[i]=0;
kk[i]=k;
}
k++;
tt-=8;
}
}for(i=1;i<=n;i++){
if(t3[i]==0 && t5[i]==0 && kk[i]==0)printf("-1");
for(j=1;j<=t3[i];j++)printf("3");
for(j=1;j<=t5[i];j++)printf("5");
for(j=1;j<=kk[i];j++)printf("8");
printf("\n");
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
8700 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
8700 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
8700 KB |
Output is correct |
2 |
Correct |
0 ms |
8700 KB |
Output is correct |
3 |
Correct |
0 ms |
8700 KB |
Output is correct |
4 |
Correct |
0 ms |
8700 KB |
Output is correct |
5 |
Correct |
0 ms |
8700 KB |
Output is correct |
6 |
Correct |
0 ms |
8700 KB |
Output is correct |
7 |
Correct |
0 ms |
8700 KB |
Output is correct |
8 |
Correct |
0 ms |
8700 KB |
Output is correct |
9 |
Correct |
0 ms |
8700 KB |
Output is correct |
10 |
Correct |
0 ms |
8700 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
118 ms |
8700 KB |
Output is correct |
2 |
Correct |
117 ms |
8700 KB |
Output is correct |
3 |
Correct |
112 ms |
8700 KB |
Output is correct |
4 |
Correct |
110 ms |
8700 KB |
Output is correct |
5 |
Correct |
120 ms |
8700 KB |
Output is correct |
6 |
Correct |
122 ms |
8700 KB |
Output is correct |
7 |
Correct |
133 ms |
8700 KB |
Output is correct |
8 |
Correct |
131 ms |
8700 KB |
Output is correct |
9 |
Correct |
131 ms |
8700 KB |
Output is correct |
10 |
Correct |
118 ms |
8700 KB |
Output is correct |
11 |
Correct |
124 ms |
8700 KB |
Output is correct |
12 |
Correct |
122 ms |
8700 KB |
Output is correct |
13 |
Correct |
114 ms |
8700 KB |
Output is correct |
14 |
Correct |
131 ms |
8700 KB |
Output is correct |
15 |
Correct |
121 ms |
8700 KB |
Output is correct |
16 |
Correct |
122 ms |
8700 KB |
Output is correct |
17 |
Correct |
105 ms |
8700 KB |
Output is correct |
18 |
Correct |
121 ms |
8700 KB |
Output is correct |
19 |
Correct |
133 ms |
8700 KB |
Output is correct |
20 |
Correct |
123 ms |
8700 KB |
Output is correct |
21 |
Correct |
118 ms |
8700 KB |
Output is correct |
22 |
Correct |
118 ms |
8700 KB |
Output is correct |
23 |
Correct |
106 ms |
8700 KB |
Output is correct |
24 |
Correct |
107 ms |
8700 KB |
Output is correct |
25 |
Correct |
115 ms |
8700 KB |
Output is correct |