#include <cstdio>
const int mx = 1000001;
int path[mx];
int stack[mx];
int main() {
for(int i=0;i<mx;i++) path[i]=-1;
path[3]=3;
path[5]=5;
path[8]=8;
for(int i=3;i+3<mx;i++) {
if( path[i] == -1 ) continue;
if( i+3 < mx && path[i+3] == -1 ) path[i+3]=3;
if( i+5 < mx && path[i+5] == -1 ) path[i+5]=5;
if( i+8 < mx && path[i+8] == -1 ) path[i+8]=8;
}
int T;
scanf("%d",&T);
while(T--) {
int n;
scanf("%d",&n);
if( path[n] == -1 ) puts("-1");
else {
int index = n, top = 0;
while(index>0) {
stack[top++] = path[index];
index -= path[index];
}
while(top-->0) printf("%d",stack[top]);
puts("");
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
8696 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
8696 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
8696 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
599 ms |
8696 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |