Submission #2591

#TimeUsernameProblemLanguageResultExecution timeMemory
2591swh0329생일수 I (GA4_birthday1)C++98
0 / 100
0 ms1080 KiB
#include <stdio.h> #include <stdlib.h> int main() { freopen("input.txt", "r", stdin); int i, t, n, n5, n3, s5, n8, t3, t5, minn; scanf("%d", &t); while(t>0) { t--; scanf("%d", &n); if(n==1 || n==2 || n==4 || n==7) {printf("-1\n"); continue;} if(n%8==0) { for(i=1;i<=n/8;i++) printf("8"); printf("\n"); continue; } n5=n/5; minn=999999999; t3=0; t5=0; for(i=n5;i>=0;i--) { s5=i*5; if((n-s5)%3==0) { n3=(n-s5)/3; n5=i; if(abs(n5-n3)<minn) { t3=n3; t5=n5; minn=abs(n5-n3); } } } n3=t3; n5=t5; if(n3>n5) { n8=n5; n3=n3-n5; n5=0; } else { n8=n3; n5=n5-n3; n3=0; } for(i=1;i<=n3;i++) printf("3"); for(i=1;i<=n5;i++) printf("5"); for(i=1;i<=n8;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...