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 |
暴力枚举900+MS水过。。。#include <iostream> using namespace std; int n,a[21][21],pow[25],ans; int main(){ //freopen("pku2531.in","r",stdin);freopen("pku2531.out","w",stdout); scanf("%d\n",&n); int i,j,k,zt,all; pow[1]=1; for(i=2;i<=23;i++)pow[i]=pow[i-1]*2; for(i=1;i<=n;i++) for(j=1;j<=n;j++)scanf("%d",&a[i][j]); all=pow[n]-1;ans=0; for(zt=1;zt<=all;zt++){ k=0; for(i=1;i<=n;i++) if((pow[i]&zt)>0) for(j=1;j<=n;j++) if((pow[j]&zt)==0) k+=a[i][j]; if(k>ans)ans=k; }; cout<<ans<<endl; return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator