#include<stdio.h>
int B[250][3]; //[0]:3,[1]:5,[2]:8
int s[250],N;
bool ch[250];
int main()
{
int i,j,k;
for(i=0;i<=80;i++){
for(j=0;3*i+5*j<=240;j++){
for(k=0;3*i+5*j+8*k<=240;k++){
int x=3*i+5*j+8*k;
if(!ch[x]){ch[x]=1;s[x]=i+j+k;B[x][0]=i;B[x][1]=j;B[x][2]=k;continue;}
if(s[x]>i+j+k || s[x]==i+j+k&&B[x][0]<i){
s[x]=i+j+k;B[x][0]=i;B[x][1]=j;B[x][2]=k;
}
}
}
}
int t;scanf("%d",&t);
while(t--){
scanf("%d",&N);
if(N==1 || N==2 || N==4 || N==7){printf("-1\n");continue;}
if(N<=240){
for(i=1;i<=B[N][0];i++)printf("3");
for(i=1;i<=B[N][1];i++)printf("5");
for(i=1;i<=B[N][2];i++)printf("8");
printf("\n");
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
888 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
888 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
888 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
884 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |