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:为什么不是0MS?In Reply To:Re:为什么不是0MS? Posted by:CSU_ACM1174 at 2011-08-04 14:49:58 #include<stdio.h> #include<string.h> #define MAX 31 int min(int a,int b,int c) { int t; t=a<b?a:b; return t<c?t:c; } int dp[MAX][MAX][MAX]; int T[MAX][MAX]; int main() { int n,m,i,j,k; scanf("%d",&n); while(n--) { scanf("%d",&m); memset(dp,0,sizeof(dp)); for(i=1;i<m;i++) for(j=i+1;j<=m;j++) scanf("%d",&T[i][j]); for(k=m-1;k>=1;k--) for(i=1;i<=k;i++) for(j=1;j<=k;j++) dp[i][j][k]=min(dp[i][j][k+1]+T[k][k+1],dp[i][k][k+1]+T[j][k+1], dp[j][k][k+1]+T[i][k+1]); printf("%d\n",dp[1][1][1]); } return 0; } 这个是0MS!! Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator