找你们学校的大牛。谁有心思在百度帮你做题。
#include#include#include#include#include#include#include#include#include#include#includeusing namespace std;typedef long long ll;int T;int n,sum;int a[25];int vis[25];bool ok;void dfs(int sun,int tot,int pos){ if(tot==4){ ok=true; return ; } if(ok) return ; for(int i=pos;i if(!vis[i]){ if(sun+a[i]==sum){ vis[i]=1; dfs(0,tot+1,0); if(ok) return ; vis[i]=0; } else if(sun+a[i] vis[i]=1; dfs(sun+a[i],tot,i+1); if(ok) return ; vis[i]=0; } } }}int main(){ scanf("%d",&T); while(T--){ sum=0; scanf("%d",&n); memset(vis,0,sizeof(vis)); for(int i=0;i scanf("%d",&a[i]); sum+=a[i]; } if(n<4 || sum%4) printf("no\n"); else{ sum/=4; ok=false; dfs(0,0,0); if(ok) printf("yes\n"); else printf("no\n"); } }return 0;}