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 ...
随机推荐
- iOS学习之根据文本内容动态计算文本框高度的步骤
在视图加载的过程中,是先计算出frame,再根据frame加载视图的,所以在设计计算高度的方法的时候,设计成加号方法; //首先给外界提供计算cell高度的方法 + (CGFloat)heightFo ...
- 关于a标签下的img元素在IE7下不能点击的问题
转载自http://segmentfault.com/q/1010000000712673<!DOCTYPE HTML> <html> <head> <met ...
- 2016ICPC China-finals 题解
A:ans=n/3,因为8=1(mod7) B: C: D:二分+贪心,二分答案,即个数,check(mid)时贪心看能不能放成mid个; E:贪心,列出不等关系,然后写个高精度分数类; F:二分+h ...
- 编译内核时出错:/bin/sh: 1: lzop: not found
http://www.deyisupport.com/question_answer/dsp_arm/sitara_arm/f/25/t/71477.aspx 在上面链接中,发现时缺少了 lzop 工 ...
- 在WPF中使用AForge.net控制摄像头拍照
原文:在WPF中使用AForge.net控制摄像头拍照 利用AForge.net控制摄像头拍照最方便的方法就是利用PictureBox显示摄像头画面,但在WPF中不能直接使用PictureBox.必须 ...
- 工厂方法模式 - OK
工厂方法模式(Factory Method),定义了一个用于创建对象的接口,让子类决定实例化哪一个类.工厂方法使一个类的实例化延迟到子类. 工厂方法模式在实现时,客户端需要决定实例化哪一个工厂来实现运 ...
- Linq to BBJECT之非延时标准查询操作符
非延时标准查询操作符是指不具备延时查询特性的标准查询操作符,这些操作符一般用于辅助延时标准查询操作符使用. 1.ToArray操作符 ToArray操作符用于将一个输入序列转换成一个数组. 方法原型: ...
- Oracle查询死锁&杀死会话
select object_name,machine,s.sid,s.serial# from v$locked_object l,dba_objects o ,v$session s where ...
- 【Latex】怎么写中文?
最近总有这么几种情况:一.作业很简单,想用Latex敲,但是英语不过硬,用中文吧配中文环境就要配置半天.二.越来越多的朋友问我怎么搞中文输入,我也确实没啥帮助人家的好办法,所以只好自己研究研究怎么配置 ...
- Address Book(地址薄)
<?xml version="1.0" encoding="UTF-8"?> <?import javafx.scene.Scene?> ...