Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
我刚学!!!贴个代码来玩玩0mstypedef struct {int xuhao;long a;} ABC; ABC abc[1500]; long x1,x2,x3; int min(int a,int b,int c) { if(a>=b) a=b; if(a>=c) a=c; return a; } int search(int x) { int i,k; for(i=0;i<=x;i++) { if(abc[i].a*5<=abc[x].a) continue; else { k=i; x1=5*abc[i].a; } break; } for(i=k;i<=x;i++) { if(abc[i].a*3<=abc[x].a) continue; else { k=i; x2=3*abc[i].a; } break; } for(i=k;i<=x;i++) { if(abc[i].a*2<=abc[x].a) continue; else { k=i; x3=2*abc[i].a; } break; } return min(x1,x2,x3); } int main() { int i,n,k=1; abc[0].xuhao=1; abc[0].a=1; abc[1].xuhao=2; abc[1].a=2; while(k==1) { scanf("%d",&n); if(n!=0) { for(i=2;i<n;i++) { abc[i].xuhao=i+1; abc[i].a=search(i-1); } printf("%ld\n",abc[n-1].a); } else k=0; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator