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. Redis—数据结构之sds

    Redis是一个Key Value数据库.Redis有5种数据类型:字符串.列表.哈希.集合.有序集合.而字符串的底层实现方法之一就是使用sds.以下描述中请读者注意区分sds是指简单动态字符串这一数 ...

  2. Resouce, platform_device 和 platform_driver 的关系【转】

    转自:http://blog.csdn.net/uruita/article/details/7278313 從2.6版本開始引入了platform這個概念,在開發底層驅動程序時,首先要確認的就是設備 ...

  3. Linux USB驱动框架分析(2)【转】

    转自:http://blog.chinaunix.net/uid-23046336-id-3243543.html   看了http://blog.chinaunix.net/uid-11848011 ...

  4. 新浪的wap网站,发现原来我们的head存在着这样的差异

    前一段时间一直被wap网站的自适应困惑…… 仔细研究了一下新浪的wap网站,发现原来我们的head存在着这样的差异…… <%@page contentType="text/html;c ...

  5. Awk基础

    Awk文本处理 awk是一种编程语言,用于在linux/unix下对文本和数据进行处理.awk数据可以来自标准输入.一个或多个文件,或其它命令的输出.awk通常是配合脚本进行使用, 是一个强大的文本处 ...

  6. 关于vc++ 6.0 编译器,点打开文件时自动关闭

    装好VC++ 6.0后,点打开文件时编译器会自动关闭掉,然后在网上找到各位大神写的资料,果然是因为之前有安装vs2010冲突的缘故,然后http://download.csdn.net/source/ ...

  7. vue总结 01基础特性

    最近有时间来总结一下vue的知识: 一.vue.js 被定义成一个开发web界面的前端库,是一个非常轻量的工具.vue.js本身具有响应式和组件化的特点. 我们不需要在维护视图和数据的统一上花费大量的 ...

  8. 用sklearn计算卡方检验P值

    情形: 1. 对于一批分类变量,我们通常要评价两两之间的相关程度. 2. 因变量是分类变量,衡量其他分类变量和因变量的相关性高低. 来源:https://blog.csdn.net/snowdropt ...

  9. Codeforces 988F Rain and Umbrellas(DP)

    题目链接:http://codeforces.com/contest/988/problem/F 题目大意: 有三个整数a,n,m,a是终点坐标,给出n个范围(l,r)表示这块区域下雨,m把伞(p,w ...

  10. CF401D 【Roman and Numbers】

    题意将n(n<=10^18)的各位数字重新排列(不允许有前导零)  求  可以构造几个mod m等于0的数字解法状压f[S][k] 表示选用的位数集合为S,mod m 为k的方案数注意不能有前导 ...