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

题目确实是按照描述的一样么?

Posted by 11061038 at 2013-06-11 21:17:27 on Problem 1651
The second line contains N integers in the range from 1 to 100, separated by spaces.
这句活的意思是不是这些数都应该在100以内呃?
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n,p[100],i,m[101][101],j,k,r,q;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&p[i]);
        for(j=0;j<n;j++)
            m[i][j]=0;
    }
    for(r=2;r<n;r++)
    {
        for(i=1;i<n-r+1;i++)
        {
            j = i + r -1;
            m[i][j]=99999999;
            for(k=i;k<j;k++)
            {
                q = m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j];
                if(q<m[i][j])
                    m[i][j]=q;
            }
        }
    }
    printf("%d\n",m[1][n-1]);
    return 0;
}
这个是从网上找来的代码,和我一直不过的代码就一点区别,我的m[i][j]=1000001,真心希望有人能给个解释,是我哪错了

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