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 |
应该是死循环了吧。。。我暴力都过了。。。In Reply To:up,过了的同志随便说一说 Posted by:bakey at 2005-08-19 19:34:50 #include<stdio.h> #define maxn 30 int i,j,n,m,ans,now; bool q[maxn]; int p[maxn][maxn]; void search(int a){ if (a>n){ if (now>ans) ans=now; return; }; int i,dome=now; q[a]=0; for (i=1;i<a;i++) if (q[i]) now+=p[a][i]; search(a+1); now=dome; q[a]=1; for (i=1;i<a;i++) if (!q[i])now+=p[a][i]; search(a+1); return; }; int main(){ scanf("%d",&n); for (i=1;i<=n;i++) for (j=1;j<=n;j++) scanf("%d",&p[i][j]); search(1); printf("%d",ans); return 0; }; Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator