问题 : 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的更多相关文章

  1. Cut the sticks

    def main(): n = int(raw_input()) arr = map(int, raw_input().strip().split()) for i in range(n): cutN ...

  2. hduoj 1455 && uva 243 E - Sticks

    http://acm.hdu.edu.cn/showproblem.php?pid=1455 http://uva.onlinejudge.org/index.php?option=com_onlin ...

  3. POJ1011 Sticks

    Description George took sticks of the same length and cut them randomly until all parts became at mo ...

  4. 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 ...

  5. hdu 1455 Sticks

    Sticks Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Statu ...

  6. DFS(剪枝) POJ 1011 Sticks

    题目传送门 /* 题意:若干小木棍,是由多条相同长度的长木棍分割而成,问最小的原来长木棍的长度: DFS剪枝:剪枝搜索的好题!TLE好几次,终于剪枝完全! 剪枝主要在4和5:4 相同长度的木棍不再搜索 ...

  7. poj 1011 Sticks

    Sticks Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 126238   Accepted: 29477 Descrip ...

  8. POJ 1011 sticks 搜索

    Sticks Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 125918   Accepted: 29372 Descrip ...

  9. poj1011 Sticks(dfs+剪枝)

    Sticks Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 110416   Accepted: 25331 Descrip ...

随机推荐

  1. Android逆向基础----Dalvik字节码

    参考此微博,更多详细内容可以到这里查看 http://blog.csdn.net/dd864140130/article/details/52076515 Dalvik字节码 1.寄存器位32位,64 ...

  2. Django学习手册 - CURD组件

    CURD CURD是一个数据库技术中的缩写词,一般的项目开发的各种参数的基本功能都是CURD.作用是用于处理数据的基本原子操作. 它代表创建(Create).更新(Update).读取(Retriev ...

  3. 【防坑指南】nginx重启后出现[error] open() “/usr/local/var/run/nginx/nginx.pid” failed

    重新启动nginx后,出现报错,原因就是下没有nginx文件夹或没有nginx.pid文件,为什么会没有呢? 原因就是每次重新启动,系统都会自动删除文件,所以解决方式就是更改pid文件存储的位置, 打 ...

  4. oracle12.2.1 坑

    1.ORA-28040: No matching authentication protocol 解决:在Oracle用户(不是grid用户)下,将$ORACLE_HOME/network/admin ...

  5. SpringMVC中前后端Date交互

    建议使用时间戳来避免日期格式带来的前后端问题,使用时间戳可以避免前后端.平台等问题. new Date().getTime()

  6. Python open() 函数

    open(file, mode='r', buffering=-1, encoding=None, errors=None, newline=None, closefd=T) 模式 描述 r 以只读方 ...

  7. 如何操控DevExpress的 SpreadSheet 控件 并与 XAF 结合应用

    DevExpress的XAF 框架通常使用 GridControl 控件来操作数据库表中的数据,但导入导出.非结构化数据的管理可以使用SpreadSheet 控件. SpreadSheet 控件模拟微 ...

  8. javascript面向对象学习

    1.this指向问题,指向的是当前的方法属于谁,当前的方法属于谁就指向谁!! 例子: oDiv.onclick = function () { this指向的是oDiv,因为这个方法属于oDiv } ...

  9. Tomcat 部署及配置

    下载,解压tomcat.jdk 1.解压,链接tomcat.jdk tar xf jdk-8u161-linux-x64.tar.gz .tar.gz .0_161/ /usr/local/ .0_1 ...

  10. matlab处理手写识别问题

    初学神经网络算法--梯度下降.反向传播.优化(交叉熵代价函数.L2规范化) 柔性最大值(softmax)还未领会其要义,之后再说 有点懒,暂时不想把算法重新总结,先贴一个之前做过的反向传播的总结ppt ...