Submission #2381

#TimeUsernameProblemLanguageResultExecution timeMemory
2381pull601생일수 I (GA4_birthday1)C++98
100 / 100
783 ms4792 KiB
#include <stdio.h> #include <stdlib.h> int d[1000001],f[9]; int main() { int n,m,i,j,kk,t=0,tt=0; d[3]=1; d[0]=1; d[5]=1; d[8]=1; scanf("%d",&n); for(i=1;i<=n;i++){ scanf("%d",&m); kk=m; for(j=1;j<=m;j++){ if(d[j-3]==1) d[j]=1; else if(d[j-5]==1) d[j]=1; else if(d[j-8]==1) d[j]=1; } if(d[m]==0){printf("%d\n",-1); continue;} while(1){ if(d[kk-8]==1){f[8]+=1; kk=kk-8; } else if(d[kk-5]==1){ f[5]+=1; kk=kk-5;} else if(d[kk-3]==1){f[3]+=1; kk=kk-3;} if(kk==0) break; } t=f[3]/4; if(t>0&&f[8]>0){ f[3]=f[3]-t*4;f[8]=f[8]-t; f[5]=f[5]+t*4;} for(j=1;j<=f[3];j++)printf("%d",3); for(j=1;j<=f[5];j++)printf("%d",5); for(j=1;j<=f[8];j++)printf("%d",8); printf("\n"); f[3]=0; f[8]=0;f[5]=0; } 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...