Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:我的方法貌似正确,结果WA,请指教下

Posted by 0810311106 at 2009-10-05 22:30:01 on Problem 1651
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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator