问题 : 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.

样例输入

  1. 9
  2. 5 2 1 5 2 1 5 2 1
  3. 4
  4. 1 2 3 4
  5. 0

样例输出

  1. 6
  2. 5
  1. #include <stdio.h>
  2. #include <algorithm>
  3. using namespace std;
  4. int main()
  5. {
  6. int n, s[65];
  7. while (scanf("%d", &n), n)
  8. {
  9. for (int i = 0; i < n; i++)
  10. scanf("%d", &s[i]);
  11. sort(s, s + n);
  12. printf("%d\n", s[0] + s[n - 1]);
  13. }
  14. return 0;
  15. }

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. Python 爬虫六 性能相关

    前面已经讲过了爬虫的两大基础模块: requests模块:用来伪造请求爬取数据 bs4模块:用来整理,提取数据 当我们真正的开始有需求的时候通常都是批量爬取url这样的.那如何批量爬取呢? 按照正常的 ...

  2. python问题:AttributeError: 'module' object has no attribute 'SSL_ST_INIT'

    AttributeError: 'module' object has no attribute 'SSL_ST_INIT' 问题背景: 下载工具wydomain,安装依赖包以后,出现下图问题. 几经 ...

  3. Hadoop环境准备

    1. 集群简介 HADOOP集群具体来说包含两个集群:HDFS集群和YARN集群,两者逻辑上分离,但物理上常在一起. HDFS集群负责海量数据的存储,集群中的角色主要有: NameNode.DataN ...

  4. ubuntu14.04安装Anaconda

    1  安装anaconda 为了安装python等各种依赖包,我安装了Anaconda工具包,在清华源下载了Anaconda的镜像 1.1  下载anaconda 如果用python2.7,就下载An ...

  5. centos设置服务开机启动失败问题

    1.安装某服务设置开机启动的时候报错 [root@node1 ~]# systemctl enable lvm2-lvmetad.serviceThe unit files have no [Inst ...

  6. nodejs -Router

    Node 用 request 事件来处理请求响应,事件内使用分支语句处理不同路径的请求,而 Express 封装了这些操作,使得代码简洁优雅 但如果请求路径变多,都写在 app.js 文件里的话,就会 ...

  7. SpringSocial业务系统与社交网站的绑定与解绑

    SpringSocial提供了了以下三个服务,我们要做的仅仅是调用它们的服务,但是SpringSocial仅仅只提供了数据,没有提供视图 ⒈拿到所有社交网站与业务系统的绑定信息 SpringSocia ...

  8. DeprecationWarning: Calling an asynchronous function without callback is deprecated. - how to find where the “function:” is?

    I recently updated my node to 7.2.1 and noticed that there is a warning coming: (node:4346) Deprecat ...

  9. This Product is covered by one or more of the following......的问题

    DELL台式机安装ubuntu后无法正常启动,黑屏显示:This Product is covered by one or more of the following...... 解决方案:进入BIO ...

  10. 消息队列:JMS之基本概念介绍

    摘要:The Java Message Service (JMS) API is a messaging standard that allows application components bas ...