Submission #2239

#TimeUsernameProblemLanguageResultExecution timeMemory
2239kriii생일수 I (GA4_birthday1)C++98
100 / 100
69 ms916 KiB
#include <stdio.h> #include <queue> std::queue<int> Q; long long V[60]; int main() { int i,x,p; for (i=0;i<60;i++) V[i] = -1; Q.push(0); V[0] = 0; while (!Q.empty()){ x = Q.front(); Q.pop(); if (x > 50) break; if (V[x+3] == -1){ Q.push(x+3); V[x+3] = V[x] * 10 + 3; } if (V[x+5] == -1){ Q.push(x+5); V[x+5] = V[x] * 10 + 5; } if (V[x+8] == -1){ Q.push(x+8); V[x+8] = V[x] * 10 + 8; } } int T; scanf ("%d",&T); while (T--){ scanf ("%d",&x); if (x <= 50) printf ("%lld",V[x]); else{ p = (x - 50 + 7) / 8; x -= p * 8; printf ("%lld",V[x]); for (i=0;i<p;i++) putchar('8'); } 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...