A semaphore initialized to one, and which is used such that it only has at most one permit available, can serve as a mutual exclusionlock.This is more...
分类:
其他好文 时间:
2014-09-20 18:29:59
阅读次数:
251
Implement pow(x, n).Analysis:The most basic idea, x multiply itself n time and return. However, this strait forward approach got time excessed. O(n).N...
分类:
其他好文 时间:
2014-09-20 01:04:26
阅读次数:
207
【Fresnel Reflection】 One of the most used types of reflections is the Fresnel reflection.One of the most used surfaces of this type of effect is the ....
分类:
其他好文 时间:
2014-09-19 19:02:35
阅读次数:
262
同Java一样,Pyton异常对象来表示异常情况。遇到错误后,引发异常,如果异常对象并未对处理或捕捉,程序就会用所谓的回溯(Traceback)来终止执行;
>>> 1/0
Traceback (most recent call last):
File "", line 1, in
ZeroDivisionError: division by zero
程序可以通过rais...
分类:
编程语言 时间:
2014-09-19 17:37:55
阅读次数:
251
fundamental integral types or extended integral types 我们先通过下图,来了解可以跨平台使用的整数类型: 之所以我们需要以上各种明确指定宽度的int类型是因为int类型本身比较特殊,其具体的字节数同机器字长和编译器有关(标准并没有规定其具体所占的字...
分类:
其他好文 时间:
2014-09-19 16:57:25
阅读次数:
296
Who Gets the Most Candies?
Time Limit: 5000MS
Memory Limit: 131072K
Total Submissions: 10234
Accepted: 3177
Case Time Limit: 2000MS
Description
N children are si...
分类:
其他好文 时间:
2014-09-19 15:40:15
阅读次数:
189
这题想到思路就很简单:从两边开始,短板往中间走。可以仔细想下,为什么这样可以保证得到最大容量?首先,从两边开始肯定是没问题的,因为包括了所有的板。为什么短板往中间走就是对的?短板是限制容器容量的,如果长板往中间走,得到的容器必然比先前的容器小(宽度减小,高度不能增加)。而短板往里走,虽然宽度减小,却...
分类:
其他好文 时间:
2014-09-18 20:37:54
阅读次数:
161
题目链接:poj 2886 Who Gets the Most Candies?
题目大意:N个人围成一圈玩约瑟夫环游戏,不同的是,步长不固定,由前一个出局的人决定,给定K表示起始的人。第i个淘汰的人将获得g(i)个糖果,问说谁获得的糖果最多。g(x)为x的因子个数。
解题思路:起始g(x)是成阶段的,所以打表处理处g(x)递增值,对于每个N,一开始找到小于等于N的最大x,那么第x个淘...
分类:
其他好文 时间:
2014-09-18 19:02:24
阅读次数:
250
Bound FoundTime Limit:5000MSMemory Limit:65536KTotal Submissions:1651Accepted:544Special JudgeDescriptionSignals of most probably extra-terrestrial or...
分类:
其他好文 时间:
2014-09-16 20:29:51
阅读次数:
210
给定数组表示的十进制数,加一操作。结果依然用十进制的数组表示。这里主要注意最高位(digit[0])依然有进位,即溢出的情况。
Given a non-negative number represented as an array of digits, plus one to the number.
The digits are stored such that the most si...
分类:
其他好文 时间:
2014-09-15 21:25:19
阅读次数:
236