Cut the sticks
def main():
n = int(raw_input())
arr = map(int, raw_input().strip().split()) for i in range(n):
cutNum = 0
minValue = min(arr)
for _ in range(n):
if 0 < arr[_] < 1001:
arr[_] -= minValue
cutNum += 1
if arr[_] <= 0: # 使不合适的值,脱衣循环
arr[_] = 1001
if cutNum != 0: # 两层循环有富裕出来,所以只输出不为0的,编码的一种动态调整
print cutNum main()
学习
尝试
pop等操作
//新的思路
n = int(raw_input().strip())
sticks = [int(i) for i in raw_input().strip().split()]
sticks.sort()
newItem = sticks[0]
count = len(sticks)
print count
count -= 1
for i in range(1, len(sticks)):
if sticks[i] != newItem:
newItem = sticks[i]
print count
count -= 1
学习
对于顺序不重要的,完全是可以进行先排序再来的
Cut the sticks的更多相关文章
- cut sticks
问题 : cut sticks 时间限制: 1 Sec 内存限制: 128 MB 题目描述 George took sticks of the same length and cut them ra ...
- 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 ...
随机推荐
- 单服务员排队模拟100天matlab实现
大家好,我是小鸭酱,博客地址为:http://www.cnblogs.com/xiaoyajiang %单服务员排队模型模拟100天 clear clc day = 100 ;s = zeros(1, ...
- angularjs中{{}} 加载出现闪烁问题
在head标签中加入 [ng-cloak] { display: none !important; } 在页面的body标签上添加 ng-cloak 可以解决页面上先后加载闪烁问题
- Intellij Idea 12 加载weblogic8X的插件
idea越用越习惯,只到idea12发布后,发现不在支持weblogic8X的server,无奈我们一批单一来源项目的coder. 后发现将idea11安装目录下plugins下的weblogicIn ...
- ASP.NET中默认的一级目录
默认一级目录结构: /Controllers – 存放负责处理 存放负责处理 URL请求的控制器类: 类:/Models – 存放表示和操纵数据以及业务对象的类: /Views – 存放负责呈现输出内 ...
- 函数call相关[ASM]
前言: __cdecl:C/C++函数默认调用约定,参数依次从右向左传递,并压入堆栈,最后由调用函数清空堆栈,这种方式适用于传递参数个数可变的被调用函数,只有被调用函数才知道它传递了多少个参数给被 ...
- C/C++捕获段错误,打印出错的具体位置(精确到哪一行)
修订:2013-02-16 其实还可以使用 glibc 的 backtrace_symbols 函数,把栈帧各返回地址里面的数字地址翻译成符号描述的 修订:2011-06-11 背景知识: · 在li ...
- hdu5072(鞍山regional problem C):容斥,同色三角形模型
现场过的第四多的题..当时没什么想法,回来学了下容斥,又听学长讲了一讲,终于把它过了 题目大意:给定n个数,求全部互质或者全部不互质的三元组的个数 先说一下同色三角形模型 n个点 每两个点连一条边(可 ...
- Address Book(地址薄)
<?xml version="1.0" encoding="UTF-8"?> <?import javafx.scene.Scene?> ...
- css备忘录(关于relative、absolute)
父级用:position: relative; 子级才能用:position: absolute; relative里面用margin调位置: absolute里面用top.left.right.bo ...
- Win32/MFC的基本概念
一.MFC的基本概念 单文档.多文档和对话框框架的区别 MFC中的类继承图的基本框架 CView类与CDocument的关系 Onpaint()和Ondraw()的关系 hdc-cdc区别联系 RUN ...