hdu 4277 USACO ORZ DFS

USACO ORZ

Time Limit: 5000/1500 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 3581    Accepted Submission(s): 1196

Problem Description
Like
everyone, cows enjoy variety. Their current fancy is new shapes for
pastures. The old rectangular shapes are out of favor; new geometries
are the favorite.
I. M. Hei, the lead cow pasture architect, is in
charge of creating a triangular pasture surrounded by nice white fence
rails. She is supplied with N fence segments and must arrange them into a
triangular pasture. Ms. Hei must use all the rails to create three
sides of non-zero length. Calculating the number of different kinds of
pastures, she can build that enclosed with all fence segments.
Two
pastures look different if at least one side of both pastures has
different lengths, and each pasture should not be degeneration.
 
Input
The first line is an integer T(T<=15) indicating the number of test cases.
The first line of each test case contains an integer N. (1 <= N <= 15)
The next line contains N integers li indicating the length of each fence segment. (1 <= li <= 10000)
 
Output
For each test case, output one integer indicating the number of different pastures.
 
Sample Input
1
3
2 3 4
 
Sample Output
1
 
 
题意
给你n个棍子,棍子可以接起来,然后问你能够拼成多少个完全不同的三角形
 
 
题解
3^15=14 348 907,所以直接暴力然后hash一下就好
 
 
 
代码
int aa[maxn];
set<int> kiss;
int n;
void dfs(int a,int b,int c,int d)
{
if(d==n)
{
if(a*b*c*d==)
return;
if(a+b>c&&a<=b&&b<=c)
{
kiss.insert(a*+b*+c);
}
return;
}
dfs(a+aa[d],b,c,d+);
dfs(a,b+aa[d],c,d+);
dfs(a,b,c+aa[d],d+);
}
int main()
{
int t;
RD(t);
while(t--)
{
kiss.clear();
RD(n);
REP(i,n)
{
RD(aa[i]);
}
dfs(,,,);
cout<<kiss.size()<<endl;
}
}
上一篇:javascript创建对象的方法--动态原型模式


下一篇:Internet与www的关系