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;
}
}

hdu 4277 USACO ORZ DFS的更多相关文章

  1. hdu 4277 USACO ORZ dfs+hash

    USACO ORZ Time Limit: 5000/1500 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Proble ...

  2. HDU 4277 USACO ORZ(DFS暴搜+set去重)

    原题代号:HDU 4277 原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=4277 原题描述: USACO ORZ Time Limit: 5000/1 ...

  3. HDU 4277 USACO ORZ(暴力+双向枚举)

    USACO ORZ Time Limit: 5000/1500 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total ...

  4. hdu 4277 USACO ORZ(dfs+剪枝)

    Problem Description Like everyone, cows enjoy variety. Their current fancy is new shapes for pasture ...

  5. hdu 4277 USACO ORZ (dfs暴搜+hash)

    题目大意:有N个木棒,相互组合拼接,能组成多少种不同的三角形. 思路:假设c>=b>=a 然后枚举C,在C的dfs里嵌套枚举B的DFS. #include <iostream> ...

  6. hdu 4277 USACO ORZ (Dfs)

    题意: 给你n个数,要你用光所有数字组成一个三角形,问能组成多少种不同的三角形 时间分析: 3^15左右 #include<stdio.h> #include<set> usi ...

  7. hdu 4277 USACO ORZ

    没什么好方法,只能用dfs了. 代码如下: #include<iostream> #include<cstring> #include<cstdio> #inclu ...

  8. HDU4277 USACO ORZ(dfs+set)

    Problem Description Like everyone, cows enjoy variety. Their current fancy is new shapes for pasture ...

  9. hdu4277 USACO ORZ

    USACO ORZ Time Limit: 5000/1500 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Sub ...

随机推荐

  1. CKEDITOR的内容js转码,C#控制器解码接收

    <script type="text/javascript" src="<%=Url.Content("~/Resource/ckeditor/ck ...

  2. http请求中的中文乱码问题

    通过浏览器访问服务器页面和资源时,不可避免地要传送中文字串,如果客户机与服务器不能用同一码表解析字串,肯定会出现各种各样的乱码问题.我总结了几个乱码场景及解决办法,如下 1.服务器上的中文字串被客户端 ...

  3. 根据经纬度坐标计算距离-python

    一.两个坐标之间距离计算 参考链接: python实现 1.Python 根据地址获取经纬度及求距离 2.python利用地图两个点的经纬度计算两点间距离 LBS 球面距离公式 美团app筛选“离我最 ...

  4. TF-池化函数 tf.nn.max_pool 的介绍

    转载自此大神 http://blog.csdn.net/mao_xiao_feng/article/details/53453926 max pooling是CNN当中的最大值池化操作,其实用法和卷积 ...

  5. [USACO16OPEN]248

    传送门啦 分析: 一个裸的区间dp,我们只需要注意合并的时候并不像2048那样加倍,每次都加1就好了 #include <iostream> #include <cstring> ...

  6. DevExpress CxGrid 隐藏 Drag a column header to group by that column

  7. EXEC与sp_executesql的区别及应用

    在项目中需要将内部DECLARE的参数通过EXEC赋值后再作为下面一个EXEC参数的时候,发现都使用EXEC时,问题就不是那么简单了.趁着没有睡意研究下.EXEC的使用与缺点EXEC命令有两种用法,一 ...

  8. 利用CE手动破解百度云下载限速!

    一步,你需要打开百度云<ignore_js_op> 第二步,你需要用上面附送的工具选择百度云进程<ignore_js_op> 第三点,不多说,看图<ignore_js_o ...

  9. windows环境下的heap spray+stack pivot gadget 实现绕过dep

    ASLR+DEP是windows平台下最为常见的两种保护手段.这两种手段使得最基础的jmp esp等手法不再适用,而单纯的堆喷也会因为堆内存不可执行而失效.那么这里就来介绍一下heap spray+s ...

  10. 【读书笔记】Android平台的漏洞挖掘和分析

    最近比较关注移动端的安全,以后也打算向安卓平台的安全发展.这篇博文主要是记录一些研究Android安全的读书笔记. Fuzzing技术的核心是样本生成技术 测试Android平台的组件间通信功能使用的 ...