| ||||||||||
| 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 | |||||||||
不知道随机化是不是这么做,老WA啊!!!#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