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 d[1000000];
int main()
{
int n,j,q,w,e,a,aa,ew=9999999,cnt,i;
scanf("%d",&n);
for(j=1; j<=n; j++){
scanf("%d",&a); ew=99999999;
for(q=0; q<=a/3; q++){
for(w=0; w<=a/5; w++){
for(e=0; e<=a/8; e++){
// printf("%d %d %d\n",q,w,e);
if(3*q+5*w+8*e==a){
if(ew>q+w+e){
ew=q+w+e;
cnt=0;
for(aa=1; aa<=q; aa++){ cnt++; d[cnt]=3; }
for(aa=1; aa<=w; aa++){ cnt++; d[cnt]=5; }
for(aa=1; aa<=e; aa++){ cnt++; d[cnt]=8; }
}
//q=a/3; w=a/5; e=a/8;
}
}
}
}
for(i=1; i<=cnt; i++) printf("%d",d[i]);
}
return 0;
}
# | 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... |