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 <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 |
---|
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... |