1. def main():
  2. n = int(raw_input())
  3. arr = map(int, raw_input().strip().split())
  4.  
  5. for i in range(n):
  6. cutNum = 0
  7. minValue = min(arr)
  8. for _ in range(n):
  9. if 0 < arr[_] < 1001:
  10. arr[_] -= minValue
  11. cutNum += 1
  12. if arr[_] <= 0: # 使不合适的值,脱衣循环
  13. arr[_] = 1001
  14. if cutNum != 0: # 两层循环有富裕出来,所以只输出不为0的,编码的一种动态调整
  15. print cutNum
  16.  
  17. main()

学习

  尝试

    pop等操作

//新的思路

  1. n = int(raw_input().strip())
  2. sticks = [int(i) for i in raw_input().strip().split()]
  3. sticks.sort()
  4. newItem = sticks[0]
  5. count = len(sticks)
  6. print count
  7. count -= 1
  8. for i in range(1, len(sticks)):
  9. if sticks[i] != newItem:
  10. newItem = sticks[i]
  11. print count
  12. count -= 1

学习

  对于顺序不重要的,完全是可以进行先排序再来的

Cut the sticks的更多相关文章

  1. cut sticks

    问题 : cut sticks 时间限制: 1 Sec  内存限制: 128 MB 题目描述 George took sticks of the same length and cut them ra ...

  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. MVC 中引入Jquery文件的几种方法

    方法1: <script src="@Url.Content("~/Scripts/jquery-1.9.1.js")" type="text/ ...

  2. Ubuntu 下安装使用文件比较合并图形工具Meld

    Meld是一款跨平台的文件比较合并工具使用Python开发,具体内容参照官网:http://meldmerge.org/ 注意以下环境要求: Requirements Python 2.7 (Pyth ...

  3. Java Timer 定时器的使用

    设置定时任务很简单,用Timer类就搞定了. 一.延时执行首先,我们定义一个类,给它取个名字叫TimeTask,我们的定时任务,就在这个类的main函数里执行. 代码如下:package test;i ...

  4. opencv视频跟踪2

    在前面的报告中我们实现了用SURF算法计算目标在移动摄像机拍摄到的视频中的位置.由于摄像机本身像素的限制,加之算法处理时间会随着图像质量的提高而提高,实际实验发现在背景复杂的情况下,结果偏差可能会很大 ...

  5. android开发学习 几个有用的学习资料~

    <Android高级应用开发-基础篇> 针对Android基础入门课程,包含了Android四大件基础.UI,Launcher等等.这个课程学习之后也是进一步深入的基础. <Andr ...

  6. 如何保存JMeter的性能测试数据到ElasticSearch上,并且使用Kibana进行可视化分析(1)

    前言 Jmeter是一款性能测试,压力测试的开源工具,被大量的测试人员拿来测试产品的性能,负载等等. Jmeter除了强大的预置的各种插件,各种可视化图表工具以外,也有些固有的缺陷,例如: 我们往往只 ...

  7. PDO如何选择其他数据库的驱动

    $dsn = "mysql(用的mysql的驱动):dbname=testdb(连接数据库名称);host=127.0.0.1(IP地址,本地是:localhost)"

  8. [转载]date命令时间转换

    Linux时间戳和标准时间的互转 在LINUX系统中,有许多场合都使用时间戳的方式表示时间,即从1970年1月1日起至当前的天数或秒数.如/etc/shadow里的密码更改日期和失效日期,还有代理服务 ...

  9. MyBatis3整合Spring3、SpringMVC3

    开发环境: System:Windows WebBrowser:IE6+.Firefox3+ JavaEE Server:tomcat5.0.2.8.tomcat6 IDE:eclipse.MyEcl ...

  10. poj 3273 Monthly Expense(二分搜索之最大化最小值)

    Description Farmer John ≤ moneyi ≤ ,) that he will need to spend each day over the next N ( ≤ N ≤ ,) ...