- 博客(12)
- 资源 (2)
- 收藏
- 关注
原创 智力题-秤球
有12个球,其中有一个和其他的重量不一样,用天平称3次把这个球找出来(1)从12个中任取8个,4对4 的称,如平衡,则从剩下的4个中再任取2个,1对1的称,如再次平衡,那么从剩下的2个中任取1个和正常的一称就行了,如第2次不平衡,那么把不平衡的2个中任一个和正常的一称就可以了(2)如第一次不平衡,那么我们暂时把第一次中重的一端的称为重球,轻的一端称为轻球,现在,把2个重球和1个轻球搭配,3
2007-10-21 17:35:00
826
原创 过桥问题
问题:在漆黑的夜里,四位旅行者来到了一座狭窄而且没有护栏的桥边。如果不借助手电筒的话,大家是无论如何也不敢过桥去的。不幸的是,四个人一共只带了一只手电筒,而桥窄得只够让两个人同时过。如果各自单独过桥的话,四人所需要的时间分别是1、2、5、8分钟;而如果两人同时过桥,所需要的时间就是走得比较慢的那个人单独行动时所需的时间。问题是,如何设计一个方案,让这四人尽快过桥。更加一般性的假设N个人过桥,所
2007-09-29 14:57:00
1372
原创 平面划分
n个点最多把直线分成C(n,0)+C(n,1)份; n条直线最多把平面分成C(n,0)+C(n,1)+C(n,2)份; n个平面最多把空间分成C(n,0)+C(n,1)+C(n,2)+C(n,3)=(n³+5n+6)/6份; n个空间最多把“时空”分成C(n,0)+C(n,1)+C(n,2)+C(n,3)+C(n,4)份.
2007-09-29 14:10:00
733
原创 topcoder problem - DifDif
problem Statement/** * @(#)DifDif.java * * * @author * @version 1.00 2007/9/6 */public class DifDif { /** * Creates a new instance of DifDif. */ public DifDif() { } pu
2007-09-06 01:06:00
638
原创 topcoder problem - CircleCount
Problem StatementSolution by Per @ topcoder #include sstream> #include algorithm> #include cmath> #include iostream> #include map> #include set> #include string> #include vector> using namespac
2007-09-04 23:18:00
679
原创 Topcoder problem - LetterInterchange
Problem StatementMy solution/** * @(#)LetterInterchange.java * * * @author foo bar * @version 1.00 2007/9/4 */public class LetterInterchange{ /** * Method interchangeWhich * @return
2007-09-02 14:55:00
640
原创 Copy-on-write and STL string
Copy-on-write(COW) 是计算机程序设计中的一种优化策略。The fundamental idea is that if multiple callers ask for resources which are initially indistinguishable, you can give them pointers to the same resource. This fict
2007-08-09 10:11:00
705
原创 MBR, disk partitioning, .... OS
A Master Boot Record (MBR), or partition sector, is the 512-byte boot sector that is the first sector ("Sector 0") of a partitioned data storage device such as a hard disk. Due to the broad populari
2007-07-06 14:23:00
869
原创 static和const的作用
static关键字至少有下列n个作用: (1)函数体内static变量的作用范围为该函数体,不同于auto变量,该变量的内存只被分配一次,因此其值在下次调用时仍维持上次的值; (2)在模块内的static全局变量可以被模块内所用函数访问,但不能被模块外其它函数访问; (3)在模块内的static函数只可被这一模块内的其它函数调用,这个函数的使用范围被限制在声明它的模块内; (4)在类中的s
2007-07-06 11:21:00
1352
1
原创 The "right-left" rule
The "right-left" rule is a completely regular rule for deciphering Cdeclarations. It can also be useful in creating them.First, symbols. Read * as "pointer to" - always on the left side
2007-07-06 11:18:00
1656
原创 File open mode in Ruby
Mode | Meaning-----+--------------------------------------------------------"r" | Read-only, starts at beginning of file (default mode).-----+--------------------------------------------------------"
2007-07-06 11:15:00
1032
原创 Gotchas in the C++ programing language
Initializer listsIn C++, it is the order of the class inheritance and of the member variables that determine the initialization order, not the order of an initializer list:#include iostream>clas
2007-01-29 20:47:00
808
Microsoft Foundation Classes (MFC) Quick Reference
2007-08-14
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人