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<stdio.h> #include<string.h> #include<math.h> #include<stdlib.h> __int64 d[10000],u[2000]; __int64 a[5000][5000]; __int64 f(__int64 n) { __int64 i,j,k,m,b2,b1,sum,min; for(i=0;i<n;i++) { u[i]=0; d[i]=a[0][i]; } u[0]=1; b1=0; for(i=0;i<n-1;i++) { for(j=0,min=1000000;j<n;j++) { if(u[j]==0) if(a[b1][j]<min&&b1!=j) { min=a[b1][j]; b2=j; } } u[b2]=1; b1=b2; // printf("%d\()()()n\n",b2); for(j=0;j<n;j++) { if(u[j]==0) { if(d[j]>a[b2][j]) d[j]=a[b2][j]; } } } for(i=0,sum=0;i<n;i++) { // printf("%d****\n",d[i]); sum=sum+d[i]; } return sum; } int main () { __int64 n,i,j,k,m,sum; // freopen("x.txt","r",stdin); // freopen("out.txt","w",stdout); while(scanf("%I64d",&n)!=EOF) { for(i=0;i<n;i++) for(j=0;j<n;j++) scanf("%I64d",&a[i][j]); sum=f(n); printf("%I64d\n",sum); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator