Submission #5758

#TimeUsernameProblemLanguageResultExecution timeMemory
5758baneling100생일수 I (GA4_birthday1)C++98
14 / 100
68 ms1088 KiB
#include <stdio.h> int T, N, num3, num5, num8, rest; void input(void) { scanf("%d",&N); num3=num5=num8=rest=0; } void output(void) { int i; for(i=1 ; i<=num3 ; i++) printf("3"); for(i=1 ; i<=num5 ; i++) printf("5"); for(i=1 ; i<=num8 ; i++) printf("8"); printf("\n"); } void process(void) { num3=N/3; rest=N%3; while(rest>0 && num3>0) { num3--; rest+=3; num5+=rest/5; rest%=5; } if(rest) printf("-1\n"); else { if(num3<num5) { num8=num3; num5-=num3; num3=0; num8+=num5/8*5; num5%=8; } else { num8=num5; num3-=num5; num5=0; num8+=num3/8*3; num3%=8; num5+=num3/5*3; num3%=5; } output(); } } int main(void) { int i; scanf("%d",&T); for(i=1 ; i<=T ; i++) { input(); process(); } 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...