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 pigengen at 2010-11-03 15:43:03 on Problem 1695
#include <cstdlib>
#include<iostream>
using namespace std;
int a[31][31];
int dp[31][31];
int main() 
{
    int T,n,i,j,maxn;
    scanf("%d",&T);
    while(T--)
    {
        scanf("%d",&n);
        for(i=1;i<n;i++)
            for(j=i+1;j<=n;j++)
                {scanf("%d",&a[i][j]);dp[i][j]=999999999;}
                //cout<<a[2][3]<<endl;
        dp[1][2]=a[1][2];
        for(j=3;j<=n;j++)
        {
             maxn=1000000000;
            if(dp[1][j-1]!=999999999)
            for(i=1;i<j;i++)
            {
                
                    if(dp[1][j-1]+a[i][j]<dp[1][j])
                    dp[1][j]=dp[1][j-1]+a[i][j];
            }
            //dp[1][j]=maxn;
        }
        //for(i=2;i<=n;i++)
        printf("%d\n",dp[1][n]);
        //printf("%d\n",dp[1][i]);
        
    }
    return 0;
}


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