이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<stdio.h>
int main()
{
int n, i, t, j, a, b, c, k, l;
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
scanf("%d", &n);
for(i=1;i<=n;i++){
scanf("%d", &t);
a = b = c = 0;
for(j=t/8;j>=0;j--){
for(k=(t-(j*8))/5;k>=0;k--){
if(j+k+((t-(j*8)-(k*5))/3)>a+b+c && (a!=0 || b!=0 || c!=0)) break;
if((t-(j*8)-(k*5))%3==0){
if(j+k+((t-(j*8)-(k*5))/3)<a+b+c || (a==0 && b==0 && c==0)){
a = j;
b = k;
c = (t-(j*8)-(k*5))/3;
}
else if(j+k+((t-(j*8)-(k*5))/3)==a+b+c){
if(a<j){
a = j;
b = k;
c = (t-(j*8)-(k*5))/3;
}
else if(a==j){
if(b<k){
a = j;
b = k;
c = (t-(j*8)-(k*5))/3;
}
}
}
}
}
}
if(a==0 && b==0 && c==0) printf("-1\n");
else{
for(j=1;j<=c;j++) printf("3");
for(j=1;j<=b;j++) printf("5");
for(j=1;j<=a;j++) printf("8");
printf("\n");
}
}
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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |