| ||||||||||
| 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>
using namespace std;
int main() {
int n,i,j,a[21];
int t,d,count;
int len,tem,tp,p;
cin>>d;
for(t=0;t<d;t++){
cin>>n;
len=0; tp=1;
for(i=0;i<n;i++) {
tp*=2;
cin>>a[i];
len+=a[i];
}
if(len%4!=0){
cout<<"no"<<endl;
continue;
}
len/=4;count=0;
for(i=0;i<tp;i++) {
p=i;
j=n-1;
tem=0;
while(p) {
tem+=a[j]*(p&1);
--j;
p>>=1;
}
if(tem==len){
++count;
if(count==4)break;
}
}
if(count==4)cout<<"yes"<<endl;
else cout<<"no"<<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