Submission #3136

#TimeUsernameProblemLanguageResultExecution timeMemory
3136movie_jo생일수 I (GA4_birthday1)C11
100 / 100
132 ms16712 KiB
#include <stdio.h> struct X { int three; int five; int eight; int sum; } x[1000001]; int main(void) { int T, n, i; x[3].three = 1; x[3].sum = 1; x[5].five = 1; x[5].sum = 1; x[6].three = 2; x[6].sum = 2; x[8].eight = 1; x[8].sum = 1; for(i = 9; i <= 1000000; i++) { if(x[i - 3].sum) { x[i] = x[i - 3]; x[i].three++; } if(x[i - 5].sum && (x[i].sum == 0 || x[i - 5].sum < x[i].sum)) { x[i] = x[i - 5]; x[i].five++; } if(x[i - 8].sum && (x[i].sum == 0 || x[i - 8].sum < x[i].sum)) { x[i] = x[i - 8]; x[i].eight++; } x[i].sum++; } scanf("%d", &T); while(T--) { scanf("%d", &n); if(x[n].sum) { for(i = 0; i < x[n].three; i++) printf("3"); for(i = 0; i < x[n].five; i++) printf("5"); for(i = 0; i < x[n].eight; i++) printf("8"); } else printf("-1"); 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...