| ||||||||||
| 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:我的方法貌似正确,结果WA,请指教下In Reply To:我的方法貌似正确,结果WA,请指教下 Posted by:mingruoyuan at 2009-01-22 16:39:23 > #include<stdio.h>
> int main()
> {
> int k,i,j,n;
> long sum,s[101][101];
> scanf("%d",&n);
> for(i=1;i<=n;i++)
> scanf("%ld",&s[i][i]);
> for(i=2;i<n;i++)
> for(j=1;j<=n-i;j++)
> for(k=j+1;k<j+i;k++)
> {
> sum=s[j][k]+s[j][j]*s[k][k]*s[i+j][i+j]+s[k][i+j];
> if(s[j][i+j]==0||s[j][i+j]>sum) s[j][i+j]=sum;
> }
> printf("%ld",s[1][n]);
> return 0;
> }
这个程序中s数组既然是dp数组,没初值怎么行呢,当然要初始化为0才能ac了。
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator