ACM: 一题DFS(深搜,剪枝) poj 1011
来源:互联网 发布:淘宝网店加盟哪家好 编辑:程序博客网 时间:2024/05/18 21:50
Description
George took sticks of the same length and cut them randomly untilall parts became at most 50 units long. Now he wants to returnsticks to the original state, but he forgot how many sticks he hadoriginally and how long they were originally. Please help him anddesign a program which computes the smallest possible originallength of those sticks. All lengths expressed in units are integersgreater than zero.
Input
The input contains blocks of 2 lines. The first line contains thenumber of sticks parts after cutting, there are at most 64 sticks.The second line contains the lengths of those parts separated bythe space. The last line of the file contains zero.
Output
The output should contains the smallest possible length of originalsticks, one per line.
Sample Input
9
5 2 1 5 2 1 5 2 1
4
1 2 3 4
0
Sample Output
6
5
题意: 给你n根小木棒,找出能恰好拼凑成最大的长度.
解题思路:
代码:
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cstring>
using namespace std;
#define MAX 70
int stick[MAX];
bool visited[MAX];
int
int sum;
int cmp(const void *a,const void *b)
{
}
int dfs(int len,int reLen,int num)
{
}
int main()
{
//
}
- ACM: 一题DFS(深搜,剪枝) poj 1011
- ACM: 深搜+剪枝 poj 1416
- poj 1190 生日蛋糕 剪枝dfs
- ACM: 一题STL map题 poj 1002 (bt…
- ACM: 深搜 poj 2676
- ACM: dfs题 poj 1321 (n皇后问题)
- ACM: 动态规划题+剪枝 toj 3904
- ACM: 一题大数求mod poj2635 (…
- ACM: 方向dfs + bfs求最短路 poj 3…
- ACM: 条件最短路 poj 1724 (没剪枝…
- ACM: 回文串 dp题 poj 1159 (滚动…
- ACM: 一题二分搜索题. poj3258 …
- ACM: 一题二分搜索题 poj3273 (…
- POj 2379 ACM Rank Table
- ACM: spfa+dfs 图论题 poj 2679
- poj Light Up dfs
- ACM: poj 1664
- ACM: poj 1050
- ACM: 图论题 poj 2240 (floyd + ST…
- ACM: 图论题 poj 1125 (题意读好久…
- ACM: 图论题 poj 2253 (poj上的dou…
- ACM: 图论题 poj 1062 (邻接矩阵+d…
- 2016"百度之星" - 资格赛(Astar Round1)(hdu5685(线段树、乘法逆元),hdu5686(大数),hdu5687(字典树),hdu5688)
- ACM: 一题DFS(深搜,剪枝) poj 1011
- ACM: 一题STL map题 poj 1002 (bt…
- ACM: 简单数学推导+挑战平台的精度…
- ACM: 初中数学 poj 1328
- ACM: 深搜 poj 2531 (一开始,居然…
- ACM: 高速打素数表 TOJ 3749 (疯狂…
- ACM: 数论 台州OJ 3151 (久违的数…
- ACM: poj 1664
- linux入门