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 ...
随机推荐
- 在IDEA中新建Spring Boot项目
新建项目 选择项目构建方式 选择项目依赖 新建项目成功后(Maven构建方式)
- 小程序view排版
<view class="bc"> <view> <text bc_text>demo</text> </view> & ...
- nginx 端口映射多个应用
nginx端口映射多个应用,应用中的静态资源路径尽量是写相对路径 server { listen 8000; location / { proxy_pass http://10.1.166.216:9 ...
- SpringSecurity权限表达式
* 当我们想要使用多个权限表达式的时候,是不能直接级联调用的,也就是说,我们只能手写了. @Override protected void configure(HttpSecurity http) t ...
- python print输出带颜色 总结
书写格式: 开头部分:\033[显示方式;前景色;背景色m + 结尾部分:\033[0m 注意:开头部分的三个参数:显示方式,前景色,背景色是可选参数,可以只写其中的某一个:另外由 ...
- U盘文件系统格式
u盘文件系统主要有FAT32.NTFS两种 ● FAT32文件系统 FAT32使用4个字节(也就是32位)的空间来表示每个扇区(Sector)配置文件的情形,故称之为FAT32.FAT16的分区容量上 ...
- 【转】采用dlopen、dlsym、dlclose加载动态链接库
1.前言 为了使程序方便扩展,具备通用性,可以采用插件形式.采用异步事件驱动模型,保证主控制逻辑不变,将各个业务以动态链接库的形式加载进来,这就是所谓的插件.linux提供了加载和处理动态链接库的系统 ...
- struts2项目搭建
把strutslib中的所有jar包添加到类路径 在src下创建struts.xml文件 <?xml version="1.0" encoding="UTF-8&q ...
- 求逆序对 ----归并排 & 树状数组
网上看了一些归并排求逆序对的文章,又看了一些树状数组的,觉得自己也写一篇试试看吧,然后本文大体也就讲个思路(没有例题),但是还是会有个程序框架的 好了下面是正文 归并排求逆序对 树状数组求逆序对 一. ...
- python操作三大主流数据库(10)python操作mongodb数据库④mongodb新闻项目实战
python操作mongodb数据库④mongodb新闻项目实战 参考文档:http://flask-mongoengine.readthedocs.io/en/latest/ 目录: [root@n ...