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 ...
随机推荐
- App 冷启动:给 Android 的 Activity 添加一个背景
2016/8/8 11:11:18 # 纠错 之前写的这篇内容的知识点有误,给大家造成了误导,深感抱歉. android 中给 Activity 设置背景的方法是在 style 文件中设置 windo ...
- python中的嵌套类(内部类调用外部类中的方法函数)
在为书中版本是3.X的,但2.X不太支持直接调用. 所以,在PYTHON2.X中,要在内部类中调用外部类的方法,就必须得实例化外部类,然后,传入实例进行调用. 花了我两个小时啊,资料没找到,自己一个一 ...
- FJ省队集训DAY1 T1
题意:有一堆兔子,还有一个r为半径的圆,要求找到最大集合满足这个集合里的兔子两两连边的直线不经过圆. 思路:发现如果有两个点之间连边不经过圆,那么他们到圆的切线会构成一段区间,那么这两个点的区间一定会 ...
- qt鼠标事件总结(坐标,跟踪,点击判断)
1.QMouseEvent中的坐标QMouseEvent中保存了两个坐标,一个是全局坐标,当然另外一个是局部坐标.全局坐标(globalPos())即是桌面屏幕坐标(screen coordinate ...
- Teach Yourself Scheme in Fixnum Days 13 Jump跳转
Jumps One of the signal features of Scheme is its support for jumps or nonlocal control. Specificall ...
- IDEA 快捷键整理
1. IDEA内存优化 \IntelliJ IDEA 9\bin\idea.exe.vmoptions ----------------------------------------- -Xms6 ...
- 【转】使用DateFormat把时间长度格式化为"时:分:秒"格式--不错
原文网址:http://ssd910.blog.163.com/blog/static/238767972010112214114201/ 经常在系统中显示时间长度,基本上每次都是显示秒数,客户觉得按 ...
- bzoj1190
题目:http://www.lydsy.com/JudgeOnline/problem.php?id=1190 神题...... F[i][j]表示容量为j*2^i+W第i-1位到第0位的最大价值, ...
- Java实现一致性Hash算法深入研究
一致性Hash算法 关于一致性Hash算法,在我之前的博文中已经有多次提到了,MemCache超详细解读一文中”一致性Hash算法”部分,对于为什么要使用一致性Hash算法和一致性Hash算法的算法原 ...
- vue-cli 脚手架总结
> vue-cli 的脚手架项目模板有browserify 和 webpack , 现在自己在用的是webpack , 官网给出了两个模板: webpack-simple 和 webpack 两 ...