
原题参见http://thinkzone.wlonk.com/MathFun/Triangle.htm。第二题果然简单些,有了第一题的经验,不多时便解出x为30度。如果需要提示信息,可以参见本篇blog的评论。建议你先不要看提示,自己想想看



After several months since I submitted my first invention disclosure (SUN080023), I saw there was $200 for "patent bonus" on my payroll of last month. And later received a notification email from the attorney, said my invention disclosure "was reviewed, and will not file a patent application".
While I'm not sure, if "reviewed" means "reviewed and approved"? After several rounds of email communication with the attorney, I confirmed, yes, it's approved, and that's why I got the bonus.
I heard that the "idt tool" will support checking status (such as PENDING, REJECTED, APPROVED, READY-TO-PATENT etc). And this would happen in the next 6 months.


class MMArray:
__file = __mem = None
__realsize = __capsize = 0
def __init__(self, type='B', fname=None, capsize=1024*1024):
self.__elmsize = struct.calcsize(type)
if not fname:
fno, self.__fname = tempfile.mkstemp("-mmarray", "pyslm-")
self.__file = os.fdopen (fno, "w+")
self.__enlarge(capsize)
else:
self.fromfile(fname)
def fromfile(self, fname):
if not os.path.exists(fname):
raise "The file '%s' does not exist!"
fsize = os.path.getsize(fname)
if fsize == 0:
raise "The size of file '%s' is zero!" % fname
if self.__mem: self.__mem.close()
if self.__file: self.__file.close()
self.__file = open (fname, "r+")
self.__mem = mmap.mmap(self.__file.fileno(), fsize)
self.__realsize = self.__capsize = fsize/self.__elmsize
def tofile(self, fname):
if fname == self.__file.name:
raise "Can not dump the array to currently mapping file!"
tf = open(fname, "w+")
bsize = self.__realsize * self.__elmsize
tf.write (self.__mem[:bsize])
tf.close()
def __enlarge(self, capsize):
if self.__capsize >= capsize:
return
self.__capsize = capsize
self.__file.seek(self.__elmsize * self.__capsize - 1)
self.__file.write('\0')
self.__file.flush()
if (self.__mem): self.__mem.close()
self.__mem = mmap.mmap(self.__file.fileno(), self.__file.tell())
def __del__ (self):
bsize = self.__realsize * self.__elmsize
self.__file.truncate (bsize)
self.__file.close()
if self.__mem: self.__mem.close()
os.remove(self.__fname)
def __getitem__(self, idx):
if idx < 0 or idx >= self.__realsize:
raise IndexError
return self.__access(idx)
def __setitem__(self, idx, buf):
if idx < 0 or idx >= self.__realsize:
raise IndexError
if type(buf) != type("") or len(buf) != self.__elmsize:
raise "Not a string, or the buffer size is incorrect!"
self.__access(idx, buf)
def __access (self, idx, buf=None):
start = idx * self.__elmsize
end = start + self.__elmsize
if not buf: return self.__mem[start:end]
self.__mem[start:end] = buf
def size(self):
return self.__realsize
def append(self, buf):
if type(buf) != type("") or len(buf) != self.__elmsize:
raise "Not a string, or the buffer size is incorrect!"
if self.__realsize >= self.__capsize:
self.__enlarge(self.__capsize*2)
self.__access(self.__realsize, buf)
self.__realsize += 1
def __iter__(self):
for i in xrange(0, self.__realsize):
yield self.__access(i)
def truncate(self, tsize):
if self.__realsize >= tsize:
self.__realsize = tsize
)。且在dict插入完之后,调用dict.keys().sort()对其key进行排序(也就是快排)。比较的结果是,两种方法使用的内存相当(大概在200M左右)。但是hash算法的速度要快一倍以上。当记录个数增加到五百万个时,结果还是差不多──即内存使用相当,hash算法快一倍。
Google released Android SDK preview today, have a look at the feature overview video. From the application development demonstration, and technical presentations (video 1, 2, and 3), you can see that Java (as a programming language) is almost everywhere, but on a different virtual machine--Dalvik Virtual Machine, a register-based (typically JVM is stack-based) virtual machine that optimized for mobile devices. Another interesting thing is, it supports OpenGL ES 1.0 specification, and the "Surface Manager" could seamlessly composite 2D and 3D graphic layers from multiple applications.
Here is the architecture of Android platform (click to enlarge):
You may download the SDK here.
经朋友的推荐,我去买了一本早已畅销多时的书──《货币战争》。一口气读完了,真是心惊肉跳。This blog copyright 2009 by yongsun