cut sticks
问题 : cut sticks
时间限制: 1 Sec 内存限制: 128 MB
题目描述
George took sticks of the same length and cut them randomly until all parts became at most 20 units long. Now he wants to return sticks to the original state, but he forgot how many sticks he had originally and how long they were originally. Please help him and design a program which computes the smallest possible original length of those sticks. All lengths expressed in units are integers greater than zero.
输入
Input consists of multiple problem instances. Each instance contains blocks of 2 lines. The first line contains the number of sticks parts after cutting, there are at most 64 sticks. The second line contains the lengths of those parts separated by the space. The last line of the file contains zero.
输出
The output should contains the smallest possible length of original sticks, one per line.
样例输入
9 5 2 1 5 2 1 5 2 1 4 1 2 3 4 0
样例输出
6 5
#include <stdio.h>
#include <algorithm>
using namespace std;
int main()
{
int n, s[65];
while (scanf("%d", &n), n)
{
for (int i = 0; i < n; i++)
scanf("%d", &s[i]);
sort(s, s + n);
printf("%d\n", s[0] + s[n - 1]);
}
return 0;
}cut sticks的更多相关文章
- Cut the sticks
def main(): n = int(raw_input()) arr = map(int, raw_input().strip().split()) for i in range(n): cutN ...
- hduoj 1455 && uva 243 E - Sticks
http://acm.hdu.edu.cn/showproblem.php?pid=1455 http://uva.onlinejudge.org/index.php?option=com_onlin ...
- POJ1011 Sticks
Description George took sticks of the same length and cut them randomly until all parts became at mo ...
- hdu.5203.Rikka with wood sticks(数学推导:一条长度为L的线段经分割后可以构成几种三角形)
Rikka with wood sticks Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/O ...
- hdu 1455 Sticks
Sticks Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit Statu ...
- DFS(剪枝) POJ 1011 Sticks
题目传送门 /* 题意:若干小木棍,是由多条相同长度的长木棍分割而成,问最小的原来长木棍的长度: DFS剪枝:剪枝搜索的好题!TLE好几次,终于剪枝完全! 剪枝主要在4和5:4 相同长度的木棍不再搜索 ...
- poj 1011 Sticks
Sticks Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 126238 Accepted: 29477 Descrip ...
- POJ 1011 sticks 搜索
Sticks Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 125918 Accepted: 29372 Descrip ...
- poj1011 Sticks(dfs+剪枝)
Sticks Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 110416 Accepted: 25331 Descrip ...
随机推荐
- 列式数据库~clickhouse问题汇总
一 简介:常见的clickhouse 问题汇总 二 问题系列 1 内存问题 Code: 241. DB::Exception: Received from localhost:9000, : ...
- TensorFlow学习笔记之--[compute_gradients和apply_gradients原理浅析]
I optimizer.minimize(loss, var_list) 我们都知道,TensorFlow为我们提供了丰富的优化函数,例如GradientDescentOptimizer.这个方法会自 ...
- tmux 简单介绍
不定期更新. 虽然一直很抵制使用linux,尤其是服务器那种无界面的东东,但是没办法还是得用.平时连接上服务器后每次要执行一个新的命令都得开一个新窗口重新连接服务器,不仅麻烦,而且有的时候服务器或者我 ...
- cartographer 安装
Debian 8 Jessie 一顿操作梦如虎,最后不知道咋装上的. 参考:https://www.jianshu.com/p/9922a51ce38f https://blog.csdn.net/p ...
- 编程基础 - 0x00008 的0x代表什么?
总结: 二进制:0dXXXX 八进制:0XXXX 十六进制:0xXXXX ------------------------------- 1- 十六进制 以“0x”开始的数据表示16进制,计算机中每位 ...
- Java 类加载机制(阿里面试题)-何时初始化类
(1)阿里的面试官问我,可以不可以自己写个String类 答案:不可以,因为 根据类加载的双亲委派机制,会去加载父类,父类发现冲突了String就不再加载了; (2)能否在加载类的时候,对类的字节码进 ...
- MySQL:Your password has expired. To log in you must change it using a client that supports expired passwords
MySQL:V5.6.37 安装后发现没远程权限,为了方便,就直接把hostname@root修改为%@root,密码修改为和localhost@root一样 然后尴尬的事情发生了,本地登陆正常,远程 ...
- python 指定日期图片文件删除
手机使用python操作图片文件 起因 前几天去国图拍了一本书,一本心理学方面的书,也许你问我为什么不去买一本,或者去网上找pdf. 其实吧,关于心理学方面的书可以说在市面上一抓就是一堆,至于拍这本书 ...
- jquery源码解析
//局部作用域,外部引用不到这个闭合函数里面的东西,这时候需要用提供的对外访问接口来访问里面的变量 (function(){ ; function $() { alert(a) } window.$ ...
- linux mount -t -o 用法
挂接命令(mount) 首先,介绍一下挂接(mount)命令的使用方法,mount命令参数非常多,这里主要讲一下今天我们要用到的. 命令格式: mount [-t vfstype] [-o optio ...