//此题枚举集合.集合达到条件后判断。 //DFS简单的枚举,枚举出各个集合。 #include<iostream> using namespace std; int n,v[22],sum,ans[22]; bool hash[22]; void dfs(int pos,int tot) { if(tot>(sum>>1))//说明此集合符合要求,进行判断 { for(int i=0;i<n;++i) { if(hash[i] && tot-v[i]<=(sum>>1))//如果第i个在集合内,且缺少第i个集合不符合要求,则第i个为。。。。 ans[i]++; } } if(pos==n-1) return; else for(int i=pos+1;i<n;++i) { if(!hash[i]) { hash[i]=true; dfs(i,tot+v[i]); hash[i]=false; } } } int main() { int cas; cin >> cas; while(cas--) { cin >> n; sum=0; memset(hash,false,sizeof(hash)); memset(ans,0,sizeof(ans)); for(int i=0;i<n;++i) { cin >> v[i]; sum+=v[i]; } for(int i=0;i<n;++i) { hash[i]=true; dfs(i,v[i]); hash[i]=false; } cout<<ans[0]; for(int i=1;i<n;++i) { cout<<' '<<ans[i]; } cout<<endl; } return 0; }