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
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.
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)
3
2 3 4
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的更多相关文章
- hdu 4277 USACO ORZ dfs+hash
USACO ORZ Time Limit: 5000/1500 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Proble ...
- HDU 4277 USACO ORZ(DFS暴搜+set去重)
原题代号:HDU 4277 原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=4277 原题描述: USACO ORZ Time Limit: 5000/1 ...
- HDU 4277 USACO ORZ(暴力+双向枚举)
USACO ORZ Time Limit: 5000/1500 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...
- hdu 4277 USACO ORZ(dfs+剪枝)
Problem Description Like everyone, cows enjoy variety. Their current fancy is new shapes for pasture ...
- hdu 4277 USACO ORZ (dfs暴搜+hash)
题目大意:有N个木棒,相互组合拼接,能组成多少种不同的三角形. 思路:假设c>=b>=a 然后枚举C,在C的dfs里嵌套枚举B的DFS. #include <iostream> ...
- hdu 4277 USACO ORZ (Dfs)
题意: 给你n个数,要你用光所有数字组成一个三角形,问能组成多少种不同的三角形 时间分析: 3^15左右 #include<stdio.h> #include<set> usi ...
- hdu 4277 USACO ORZ
没什么好方法,只能用dfs了. 代码如下: #include<iostream> #include<cstring> #include<cstdio> #inclu ...
- HDU4277 USACO ORZ(dfs+set)
Problem Description Like everyone, cows enjoy variety. Their current fancy is new shapes for pasture ...
- hdu4277 USACO ORZ
USACO ORZ Time Limit: 5000/1500 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Sub ...
随机推荐
- mariadb/mysql使用Navicat连接报错
[问题1] 使用Navicat连接服务器的mariadb/mysql时报错 access denied for user root@192.168.xx.xx(using password:yes) ...
- Angular CLI 命令行工具
工欲善其事必先利其器.好的工具让开发更加简单便捷. 1.全局安装angular cli npm install -g @angular/cli 2.安装完成后就可以使用angular-cli命令行工具 ...
- python基础--类的方法
一:类的方法说明 类的方法分为实例方法,析构方法,构造方法,类方法,静态方法,属性方法,等等 类方法和静态方法都可以被类和类实例调用,类实例方法仅可以被类实例调用 类方法的隐含调用参数是类,而类实例方 ...
- OR 连接查询注意
用or 查询时, 取得是 每个or中条件的 查询的结果集union. select * from categorysecond t where ISNULL(null); ort.csid in (' ...
- maven pom.xml配置
<repositories> <repository> <id>central</id> <name>Maven Repository Sw ...
- mysql慢sql报警系统
前言:最近有同事反应有的接口响应时间时快时慢,经过排查有的数据层响应时间过长,为了加快定位定位慢sql的准确性,决定简单地搭建一个慢sql报警系统 具体流程如下架构图 第一步:记录日志 每个业务系统都 ...
- MySQL学习笔记:delete
使用 SQL 的 DELETE FROM 命令来删除 MySQL 数据表中的记录. 语法: DELETE FROM table_name [WHERE Clause] 如果没有指定 WHERE 子句, ...
- 【直播预告】云栖直播:阿里热修复产品HotFix2.0升级详解
全面——你知道吗?1891年,卡尔森纳做出的第一把瑞士军刀,只有螺丝刀和开罐器.经过一代又一代能工巧匠的打磨,这把刀陆续增加了锯子.剪刀.镊子.放大镜.改锥,甚至内藏激光.LED手电筒.USB记忆碟等 ...
- xtrabckup备份报错:Failed to connect to MySQL server: Can't connect to local MySQL server through socket '/data/mysql/mysql.sock' (2).
1.做软连接 [root@xxxxxx:/data/backup/log]# ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock [root@xxxxxxx ...
- linux删除特殊字符命名的文件
今天在服务器上不小心创建了一个!命名的文件还有一个\命名的文件,本来想用转义字符进行删除,又担心误删了项目文件....最后找到最好的解决办法 如下: ls -i 查看文件inum值 执行删除inum ...