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 |
Re:怎末总超时In Reply To:怎末总超时 Posted by:songhaiyang at 2010-01-31 14:34:42 > #include<stdio.h> > int c[200],n; > void main() > { > int dp(int a,int b); > int i; > scanf("%d",&n); > for(i=0;i<n;i++) > scanf("%d",&c[i]); > printf("%d\n",dp(0,n-1)); > } > int dp(int a,int b) > { > int i,min=1000001; > if(b-a<=1) > return 0; > else if(b-a==2) > return (c[a]*c[a+1]*c[b]); > else > { > for(i=a+1;i<b;i++) > { > if(min>dp(a,i)+dp(i,b)+c[a]*c[i]*c[b]) > min=dp(a,i)+dp(i,b)+c[a]*c[i]*c[b]; > } > return min; > } > } > Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator