冒泡排序:1 def bubble(l):2 length = len(l)3 for i in range(length):4 for j in range(i+1, length):5 if l[i] > l[j]:6 ...
分类:
编程语言 时间:
2014-08-06 22:23:07
阅读次数:
223
原文地址:http://infiniteloop.in/blog/quick-python-performance-optimization-part-i/
往往小的改变却能带来大的性能提升,
下面说下python中的几点性能优化。
1.使用timeit模块
2.减少函数的调用次数
3.使用xrange代替range
4.''.join()代替+,+=
5.while 1 代替 wh...
分类:
编程语言 时间:
2014-08-06 19:28:32
阅读次数:
247
RMQ算法,是一个快速求区间最值的离线算法,预处理时间复杂度O(n*log(n)),查询O(1),所以是一个很快速的算法,当然这个问题用线段树同样能够解决。
问题:给出n个数ai,让你快速查询某个区间的的最值。
算法分类:DP+位运算
算法分析:这个算法就是基于DP和位运算符,我们用dp【i】【j】表示从第 i 位开始,到第 i + 2^j 位的最大值或者最小值。
...
分类:
其他好文 时间:
2014-08-06 18:58:52
阅读次数:
222
1:编写一个程序,确定分别由signed ,unsigned 限定的char short long int的取值范围。采用打印标准头文件中的相应值以及直接计算两种方式实现。头文件的实现方式:#include #include /*determin range of int types*/int ma...
分类:
其他好文 时间:
2014-08-06 14:14:51
阅读次数:
229
We hold expertise in manufacturing a wide range of Industrial machines Sand Making Machine that find application in various purposes. Manufactured as ...
分类:
其他好文 时间:
2014-08-06 11:42:11
阅读次数:
271
Go编程基础
Go的内置关键字(25个)
不多
break default func interface select
case defer go map struct
chan else goto package switch
const fallthrough if range type
continute for import return var
Go的注释方...
分类:
其他好文 时间:
2014-08-06 01:56:50
阅读次数:
313
Problem Description:
Given a roman numeral, convert it to an integer.
Input is guaranteed to be within the range from 1 to 3999.
分析:题目的意思是将罗马数字转化成整数,首先是在网上找到关于罗马数字表示法的规则如下:
1、计数方法:① 罗马数字就...
分类:
其他好文 时间:
2014-08-05 22:45:10
阅读次数:
283
1:Python定义数组:a=[0,1,2,3,4] ; 打印数组list(a); 这时:a[0]=0, a[1]=1, a[[2]=2......1.1:如果想定义一个很长的数组可以用到python函数range a=range(1000)生成1000个元素的一维数组, list(a) 打印数组显...
分类:
编程语言 时间:
2014-08-05 15:39:29
阅读次数:
251
A Magic Lamp
Time Limit: 2000/1000 MS (Java/Others) Memory Limit:
32768/32768 K (Java/Others)
Problem Descripti...
分类:
其他好文 时间:
2014-08-05 11:23:19
阅读次数:
240
Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999. 1 public class Solution { 2 public int ...
分类:
其他好文 时间:
2014-08-05 11:02:09
阅读次数:
242