This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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++) printf ("8");
}
printf ("\n");
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |