HDU 4277 USACO ORZ
2013-12-14 20:04
344 查看
题意:题目给出n条边 , 要求用这n条组成一个三角形 , 问最多能成多少个三角形?
这题真的是一个水题 , 可能当时题目读错了(英文差啊) , 后面做得时候又一直超时 ,
看大神的解题报告之后才知道真的很简单。
简单的搜索加判重
判重可以用 hash 、 set+运算符重载
代码:
#include
#include
#include
#include
#include
#include
#include
#define LL
long long
#define N
25
using
namespace std;
int
num
;
int
n,summ,xj,xk;
int
Case;
struct
node //要去学学
{
int x,y,z;
bool operator < (const struct node &a)
const
{
return (x!=a.x)?(x
}
}temp,ans;
set
hashx;
void
dfs(int);
int
main()
{
scanf("%d",&Case);
for(int c=0;c
{
summ=0;hashx.clear();
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
scanf("%d",&num[i]);
summ+=num[i];
}
temp.x=num[1];temp.y=0;
这题真的是一个水题 , 可能当时题目读错了(英文差啊) , 后面做得时候又一直超时 ,
看大神的解题报告之后才知道真的很简单。
简单的搜索加判重
判重可以用 hash 、 set+运算符重载
代码:
#include
#include
#include
#include
#include
#include
#include
#define LL
long long
#define N
25
using
namespace std;
int
num
;
int
n,summ,xj,xk;
int
Case;
struct
node //要去学学
{
int x,y,z;
bool operator < (const struct node &a)
const
{
return (x!=a.x)?(x
}
}temp,ans;
set
hashx;
void
dfs(int);
int
main()
{
scanf("%d",&Case);
for(int c=0;c
{
summ=0;hashx.clear();
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
scanf("%d",&num[i]);
summ+=num[i];
}
temp.x=num[1];temp.y=0;
相关文章推荐
- poj 1836 最长增长序列的变形
- 集合中子集的生成算法
- poj 1742
- LA 4726 Average
- 动态规划求 最长递增子序列
- 01背包和完全背包比较容易忽略的地…
- Distant Galaxy poj 3141
- unipue() 函数的功能
- poj 2015 Permutation Code
- poj 1088 经典的记忆化搜索
- 中位数的应用
- poj 1724
- poj1511(第一次用数组模拟邻接表…
- poj 2226
- poj2728最优比率生成树
- poj 1797
- poj 1251
- 余弦:我的渗透利器
- 从数据库存储,文件结构谈到B树,散列
- poj 1364