Submission #16365

#TimeUsernameProblemLanguageResultExecution timeMemory
16365eaststar생일수 I (GA4_birthday1)C++14
100 / 100
867 ms13316 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...