先回顾列表解释1 lista = range(10)2 listb = [elem * elem for elem in lista]那么listb就将会是0至9的二次方。现在有这么一个需求,需要存储前10个斐波那契数到硬盘。那么先写产生斐波那契数的函数:1 def fib(max):2 n...
分类:
编程语言 时间:
2014-09-30 01:24:31
阅读次数:
453
chr()函数用一个范围在range(256)内的(就是0~255)整数作参数,返回一个对应的字符。 unichr()跟它一样,只不过返回的是Unicode字符,这个从Python 2.0才加入的unichr()的参数范围依赖于你的Python是如何被编译的。如果是配置为USC2的Unicode,那...
分类:
其他好文 时间:
2014-09-29 15:51:51
阅读次数:
217
the Sum of Cube
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 405 Accepted Submission(s): 224
Problem Description
A range is g...
分类:
其他好文 时间:
2014-09-28 18:03:45
阅读次数:
135
Problem Description
A range is given, the begin and the end are both integers. You should sum the cube of all the integers in the range.
Input
The first line of the input is T(1
Each...
分类:
其他好文 时间:
2014-09-28 01:35:40
阅读次数:
151
列表生成式即List Comprehensions,是Python内置的非常简单却强大的可以用来创建list的生成式。举个例子,要生成list[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]可以用range(1, 11):>>> range(1, 11)[1, 2, 3, 4, 5, ...
分类:
编程语言 时间:
2014-09-27 16:08:09
阅读次数:
218
SVN的merge操作是为了保证主干(trunk)和分支(branch)同步,merge方式有:1、Merge a range of revisions(合并一个范围的版本)2、Reintegrate a branch(复兴合并)3、Merge two different trees(合并两个不同的...
分类:
其他好文 时间:
2014-09-27 14:49:09
阅读次数:
183
本题是利用后缀数组求最长的回文串。方法是将字符串反转之后拼接到原来的字符串末尾,中间用一个没有出现过的分割符隔开,原因是防止最长公共前缀横跨两个串。之后分别枚举回文串的中点,以及回文串长度是奇数还是偶数,看一下对应位置的最长公共前缀即可。这里的求最长公共前缀要处理RMQ问题,线段树固然可以解决,但是...
分类:
其他好文 时间:
2014-09-26 22:10:08
阅读次数:
142
UVA12299 - RMQ with Shifts(线段树)
题目链接
题目大意:要求你查询某一段的最小值,但是还有一个shift操作,将(a0, a1, a2, a3..ak)这个K个位置的数字互相对掉,例如a0位置的值变成a1,a1位置的值变成a2...ak位置的值变成a0.
解题思路:因为shift后面的操作数最多30个,所以可以用线段树单点修改。复杂度n*logn。用s...
分类:
其他好文 时间:
2014-09-26 10:40:58
阅读次数:
199
Description
A musical melody is represented as a sequence of N (1<=N<=20000)notes that are integers in the range 1..88, each representing a key on the piano. It is unfortunate but true that this ...
分类:
其他好文 时间:
2014-09-25 23:11:58
阅读次数:
239