Submission #2299

#TimeUsernameProblemLanguageResultExecution timeMemory
2299rbwhddl2000생일수 I (GA4_birthday1)C++98
100 / 100
133 ms8700 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...