Submission #2323

#TimeUsernameProblemLanguageResultExecution timeMemory
23236590f1생일수 I (GA4_birthday1)C++98
100 / 100
73 ms884 KiB
#include<stdio.h> int main() { int n,a=0,b=0,c=0,k,i,j,t; scanf("%d",&t); for(i=1;i<=t;i++){ a=0;b=0;c=0; scanf("%d",&n); a=n/3; k=n%3; if(k==1){ if(a>=5){a=a-5;c=c+2;k=0;} else if(a>=3){a=a-3;b=b+2;k=0;} } if(k==2){ if(a>=2){c++;a=a-2;k=0;} else if(a>=1){b++;k=0;a--;} } if(a>=8){c=c+(a/8)*3;a=a%8;} if(a>=5){b=b+(a/5)*3;a=a%5;} if(b>=8){c=c+(b/8)*5;b=b%8;} if(a>0 && b>0){ if(a>=b){c=c+b;a=a-b;b=0;} if(a<b){c=c+a;b=b-a;a=0;} } if(a>=4 && c>=1){ a=a-4; c--; b=b+4; } if(k==0){ for(j=1;j<=a;j++)printf("3"); for(j=1;j<=b;j++)printf("5"); for(j=1;j<=c;j++)printf("8"); } else printf("-1"); 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...