Submission #2716

#TimeUsernameProblemLanguageResultExecution timeMemory
2716hana5505생일수 I (GA4_birthday1)C++98
100 / 100
188 ms1088 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...