#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
int t,a[25],b[25],n,sum;
bool cmp(int a ,int b)
{
return a>b;//降序
}
bool dfs(int coun,int num,int goal)
{
if(coun==3)
return true;
for(int i=num;i<n;i++)
{
if(b[i]==true)
continue;
b[i]=true;
if(a[i]==goal)
{
if(dfs(coun+1,0,sum/4))//coun+1后“从头开始”
return true;
}
else if(a[i]<goal)
{
if(dfs(coun,i+1,goal-a[i]))
return true;
}
b[i]=false;
}
return false;
}
int main()
{
scanf("%d",&t);
while(t--)
{
sum=0;
memset(a,0,sizeof(a));
memset(b,false,sizeof(b));
scanf("%d",&n);
for(int i=0;i<n;i++)
{
scanf("%d",&a[i]);
sum+=a[i];
}
if(sum%4)//不为0时执行,边必须为整数
{
printf("no\n");
continue;
}
sort(a,a+25,cmp);
int goal=sum/4;
if(dfs(0,0,goal))
printf("yes\n");
else
printf("no\n");
}
return 0;
}
04-07
3637
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
09-01
07-18