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 |
那位大牛帮忙看一下怎么过不了啊#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator