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 |
每次随机将一个点改变分组就行了。最多不用10w次就几乎保证AC了。In Reply To:不知道随机化是不是这么做,老WA啊!!! Posted by:IamI at 2005-08-06 15:42:00 > #include<iostream.h> > #include<stdlib.h> > > void main(){ > int i,j,n,n2,time,a[20],t[20][20]; > long sum,max; > > cin>>n; max=-1; n2=(n+1)/2; > for(i=0;i<n;i++) > for(j=0;j<n;j++) > cin>>t[i][j]; > > time=200000; > > while(time--){ > sum=0; > > for(i=0;i<n;i++) a[i]=0; > > for(i=0;i<n2;i++) a[rand()%n]=1; > > for(i=0;i<n;i++) > for(j=0;j<n;j++) > if( (a[i]) && (!a[j]) ) sum+=t[i][j]; > > if(sum>max) max=sum; > } > > cout<<max<<endl; > } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator