2014年1月10日

摘要: Problem:Given n points on a 2D plane, find the maximum number of points that lie on the same straight line.Suppose that the structure Point is already defined in as following:/** * Definition for a point. * struct Point { * int x; * int y; * Point() : x(0), y(0) {} * Point(int a, int... 阅读全文

posted @ 2014-01-10 10:53 卢泽尔 阅读(2351) 评论(1) 推荐(0)

摘要: 在这里我将搜集一些神奇的Python代码,希望能不断更新。。。1. List Comprehensions使用list comprehension可以杜绝掉50%以上的for循环,后者的效率极其低下(可以看看C源码的实现),而且不够紧凑。(1) Python官方的例子:>>> [(x, y) for x in [1,2,3] for y in [3,1,4] if x !=y]运行结果得到:[(1, 3), (1, 4), (2, 3), (2, 1), (2, 4), (3, 1), (3, 4)](2) list的反转:lis[::-1](3) 找n以内的质数:>& 阅读全文

posted @ 2014-01-10 01:26 卢泽尔 阅读(2884) 评论(0) 推荐(0)

摘要: 整理一篇网上神文《完全用Python工作---Harness the power of Python》,借以增强自己对Python的信心!Python彩蛋:在python解释器里输入import antigravityPython是荷兰人Guido van Rossum1991年开发完成的脚本解释语言。起这个脑缺的名字是因为他是一个叫做Monty Python的脑缺喜剧团体的脑残粉(BTW,Monty Python出演的巨蟒与圣杯是英国电影史上跟大话西游同样地位的喜剧,其中亚瑟王被黑成了炭,里面圆桌骑士们拿着块石头敲来敲去各处蹦达着,看影评我才知道这是表示他们在骑马……于是人们知道以这么脑残的 阅读全文

posted @ 2014-01-10 00:52 卢泽尔 阅读(323) 评论(0) 推荐(0)