This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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");
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |