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:给大家一个能过得代码,如果哪位有建议,请一定告诉我!In Reply To:给大家一个能过得代码,如果哪位有建议,请一定告诉我! Posted by:F117 at 2007-04-07 01:11:18 > #include<stdio.h> > int F[31][31][31]; > int L[31][31]; > int main() > { > int M; > // freopen("in.txt","r",stdin); > scanf("%d",&M); > while(M--) > { > int N; > scanf("%d",&N); > for(int i=1;i<=N-1;++i) > for(int j=i+1;j<=N;++j) > { > scanf("%d",&L[i][j]); > F[i][j][N]=0; > } > for(int c=N-1;c>=1;c--) > { > for(int a=1;a<=c;a++) > for(int b=1;b<=c;b++) > { > int t1,t2,t3; > t1=F[b][c][c+1]+L[a][c+1]; > t2=F[a][c][c+1]+L[b][c+1]; > t3=F[a][b][c+1]+L[c][c+1]; > int min=t1; > if(t2<min)min=t2; > if(t3<min)min=t3; > F[a][b][c]=min; > } > } > printf("%d\n",F[1][1][1]); > } > return 0; > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator