#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");
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
16712 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
16712 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
16712 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
88 ms |
16712 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |