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 <bits/stdc++.h>
int D[1000010]={1},p[1000010];
void ans(int x){
if(!x)return;
ans(p[x]);
printf("%d",x-p[x]);
}
int main(){
int i,n,t;
for(i=3;i<=1e6;++i){
if(D[i-3])D[i]=D[i-3]+1,p[i]=i-3;
if(i>4&&D[i-5]&&(!D[i]||D[i]>D[i-5]))D[i]=D[i-5]+1,p[i]=i-5;
if(i>7&&D[i-8]&&(!D[i]||D[i]>D[i-8]))D[i]=D[i-8]+1,p[i]=i-8;
}
scanf("%d",&t);
for(;t--;){
scanf("%d",&n);
if(D[n])ans(n),puts("");
else puts("-1");
}
return 0;
}
# | 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... |