标签:
#include<iostream> #include<cstdio> #include<cstring> #include<cstdlib> #include<algorithm> #include<set> using namespace std; const int maxn=1000100; typedef long long ll; int T; int a,b,c; int l[maxn],n; set<ll> s; void dfs(int i) { if(i==n+1){ if(a&&a<=b&&b<=c&&a+b>c){ if(s.find((a<<16)|b)==s.end()) s.insert((a<<16)|b); } return; } a+=l[i];dfs(i+1);a-=l[i]; b+=l[i];dfs(i+1);b-=l[i]; c+=l[i];dfs(i+1);c-=l[i]; } int main() { cin>>T; while(T--){ cin>>n; for(int i=1;i<=n;i++) scanf("%d",&l[i]); s.clear(); a=b=c=0; dfs(1); cout<<(int)s.size()<<endl; } return 0; }
标签:
原文地址:http://www.cnblogs.com/--560/p/4782233.html