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>
struct X {
int exist;
int three;
int five;
int eight;
} x[1000001];
int main(void)
{
int T, n, i;
x[1].exist = -1;
x[2].exist = -1;
x[4].exist = -1;
x[7].exist = -1;
x[3].three = 1;
x[5].five = 1;
x[6].three = 2;
x[8].eight = 1;
for(i = 9; i <= 1000000; i++)
{
if(x[i - 8].exist == 0)
{
x[i].three = x[i - 8].three;
x[i].five = x[i - 8].five;
x[i].eight = x[i - 8].eight + 1;
}
else if(x[i - 5].exist == 0)
{
x[i].three = x[i - 5].three;
x[i].five = x[i - 5].five + 1;
x[i].eight = x[i - 5].eight;
}
else
{
x[i].three = x[i - 3].three + 1;
x[i].five = x[i - 3].five;
x[i].eight = x[i - 3].eight;
}
}
scanf("%d", &T);
while(T--)
{
scanf("%d", &n);
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");
printf("\n");
}
}
# | 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... |