标签:des blog http io ar os sp java for
Time Limit: 5000/1500 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 3439 Accepted Submission(s): 1164
#include<iostream> #include<cstdio> #include<cstring> #include<cstdlib> #include<string> #include<cmath> #include<algorithm> #include<queue> #include<vector> #include<set> using namespace std; set<long long> sset; int t,n,aar[20]; void dfs(int a,int b,int c,int rt) { if(rt==n) { if(a>b||b>c||a>c) return ; if(a&&b&&c&&(a+b)>c) { long long temp=100000000*a+1000000*b+c; sset.insert(temp); } return ; } dfs(a+aar[rt],b,c,rt+1); dfs(a,b+aar[rt],c,rt+1); dfs(a,b,c+aar[rt],rt+1); } int main() { scanf("%d",&t); while(t--) { sset.clear(); scanf("%d",&n); for(int i=0;i<n;i++) scanf("%d",&aar[i]); dfs(0,0,0,0); printf("%I64d\n",sset.size()); } return 0; }
标签:des blog http io ar os sp java for
原文地址:http://www.cnblogs.com/a972290869/p/4108592.html