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 ...
随机推荐
- 【tmos】字段update_time如何动态的更新
1.数据库设置 2.数据库不设置,用Jpa的注解来完成 @EnableJpaAuditing注解 @SpringBootApplication @EnableJpaAuditing public cl ...
- Web项目笔记(一)JSONP跨域请求及其概念
https://blog.csdn.net/u014607184/article/details/52027879 https://blog.csdn.net/saytime/article/deta ...
- 一张图片资源要占用多大内存xhdpi xxhdpi
一张图片资源要占用多大内存,可以用下面的计算公式计算 4 * withPixel*(targetDensity /sourcedensity) * heightPixel*(targetDensity ...
- 【Convex Optimization (by Boyd) 学习笔记】Chapter 2 - Convex sets(1) 仿射集&凸集
I. 仿射凸集(Affine and convex sets) 1. 线与线段 假设\(R^n\)空间内两点\(x_1,x_2\, (x_1≠x_2)\),那么\(y=\theta x_1+(1-\t ...
- 用NAME_N带入NAME 让显示格式变为 姓名(类型),类型在数据库中是1和0,显示效果为姓名(1),SQL写法
select xxxx T.PROJECT_NAME||'('||DECODE(T.PROJECT_TYPE,'1','收入','2','支出','3','挂账')||')' PROJECT_NAME ...
- 修改Spring Social默认提交地址
⒈ package cn.coreqi.social.config; import org.springframework.social.security.SocialAuthenticationFi ...
- 【python网络爬虫】之requests相关模块
python网络爬虫的学习第一步 [python网络爬虫]之0 爬虫与反扒 [python网络爬虫]之一 简单介绍 [python网络爬虫]之二 python uillib库 [python网络爬虫] ...
- FlowNet2.0 安装指南
 \(安装环境: \color{red}{Ubuntu16.04 + CUDA8.0 + cuDNN5.0}\) 安装 CUDA CUDA 安装准备 CUDA 官方安装文档 首先查看是否电脑具有支持 ...
- 数字证书及CA的扫盲介绍
★ 先说一个通俗的例子 考虑到证书体系的相关知识比较枯燥.晦涩.俺先拿一个通俗的例子来说事儿. ◇ 普通的介绍信 想必大伙儿都听说过介绍信的例子吧?假设 A 公司的张三先生要到 B 公司去拜访,但是 ...
- MySQL索引操作
创建普通索引 CREATE INDEX index_name ON table_name(column1,column2); 另一种建立方式: ALTER TABLE table_name ADD I ...