#include <cstdio>
using namespace std;
int T, N;
int threes, fives, eights;
unsigned int i;
int t[8] = {0, 3, 0, 1, 0, 0, 2, 0};
int f[8] = {0, 0, 2, 0, 4, 1, 0, 3};
int e[8] = {0, 1, 1, 0, 2, 0, 0, 1};
int small[8] = {-1, -1, -1, 3, -1, 5, 33, -1};
void makeinput(char c, int count) {
while (count--) {
printf("%c", c);
}
}
int hap(long long int a) {
int res = 0;
while (a) {
int tmp = a % 10;
if (tmp == 3 || tmp == 5 || tmp == 8);
else return 0;
res += a % 10;
a /= 10;
}
return res;
}
int main() {
scanf("%d", &T);
while (T--) {
threes = fives = eights = 0;
//scanf("%d", &N);
N = T;
if (N == 12) {
printf("3333\n");
continue;
} else if (N < 8) {
printf("%d\n", small[N]);
continue;
}
eights = N / 8;
N %= 8;
threes += t[N]; fives += f[N]; eights -= e[N];
makeinput('3', threes);
makeinput('5', fives);
makeinput('8', eights);
printf("\n");
for (i=1;; ++i) {
if (hap(i) == T) {
break;
}
}
printf("%d\n", i);
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
884 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1000 ms |
0 KB |
Program timed out |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1000 ms |
0 KB |
Program timed out |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1000 ms |
0 KB |
Program timed out |
2 |
Halted |
0 ms |
0 KB |
- |