问题 : 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;
}

最新文章

  1. python 培训之 Python 数据类型
  2. hdu 1047 (big integer sum, fgets or scanf, make you func return useful infos) 分类: hdoj 2015-06-18 08:21 39人阅读 评论(0) 收藏
  3. c++字符串变量---8
  4. SQL Server之存储过程基础知识
  5. 监控mysql主从同步状态脚本
  6. mysql 执行流程
  7. AIX topas命令详解
  8. 手工构建ISO的基本步骤
  9. Android中的Apk的加固(加壳)原理解析和实现
  10. 无法关闭的QT程序(覆盖closeEvent,新建QProcess并脱离关系)
  11. linux计算程序运行时间
  12. Java 位运算符和 int 类型的实现
  13. 关于js的书写
  14. kprobe原理解析
  15. Shell-3--变量
  16. hdu5583
  17. java实验五——字符数组、String、StringBuffer的相互转化,StringBuffer的一些方法
  18. kafka简介【转】
  19. python3对数据库的基本操作
  20. swift百度地图api

热门文章

  1. Maven项目在更新过程停止,再更新无效--&gt;解决
  2. synchronized与Lock的区别与使用
  3. nutz学习笔记(1)
  4. light oj 1011 - Marriage Ceremonies
  5. 【转载】AutoML--超参数调优之Bayesian Optimization
  6. 第五节,损失函数:MSE和交叉熵
  7. linux 制作U盘启动,和定制系统
  8. 【运维】Dell R710如何做Raid0与Raid5
  9. Python3-lamba表达式、zip函数
  10. 【转】Java的接口和抽象类