Submission #2438

#TimeUsernameProblemLanguageResultExecution timeMemory
2438rkdrjs0327생일수 I (GA4_birthday1)C++98
100 / 100
676 ms8696 KiB
#include<stdio.h> struct data { int last,val; }; data dy[1000001]; void setting() { int i,c1,c2,c3; for(i=1; i<=1000000; i++) dy[i].val=dy[i].last=999999999; dy[3].last=3; dy[3].val=1; dy[5].last=5; dy[5].val=1; dy[6].last=3; dy[6].val=2; dy[8].last=8; dy[8].val=1; for(i=9; i<=1000000; i++){ c1=dy[i-3].val+1; c2=dy[i-5].val+1; c3=dy[i-8].val+1; if(c1<=c2 && c1<=c3){ dy[i].last=3; dy[i].val=c1; } else if(c2<=c3 && c2<=c3){ dy[i].last=5; dy[i].val=c2; } else if(c3<=c1 && c3<=c2){ dy[i].last=8; dy[i].val=c3; } } } void process() { int a,ind; scanf("%d",&a); ind=a; if(dy[ind].val>=999999999) printf("-1"); else{ while(ind){ printf("%d",dy[ind].last); ind-=dy[ind].last; } } printf("\n"); } void input() { int n,i; scanf("%d",&n); for(i=1; i<=n; i++) process(); } int main() { setting(); input(); 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...