2009-05-13 14:05
1. 检查括号匹配(在左右括号间切换): Ctrl +] |
2009-04-22 14:15
请问, 正则表达式能完成这样的功能么?
别人有个一字符串数组, 已知数组的每个元素匹配 ^[a-z]+$
,现在那个人把数组中的所有字符串串成一个,分隔符用空格。
比如数组 p = {“abc”, “cdd”, “xxx”,”abc”}, 我收到的结果是 “abc cdd xxx abc”.
我的问题是能不能写一个正则表达式,来判定他原来的数组里没有重复元素。
也就是假设这个正则表达式是 regex = ….
那么regex.IsMatch(“abc cdd xxx abc”) 返回 false.
Re |
2009-04-01 17:08
: 某人有M个相同的蛋,有一天,它想试验一下蛋的硬度。他是通过不断从一座N层楼高的楼上往下扔蛋来确定蛋的硬度X。
: 给定M和N,求出最坏情况下,要保证试验成功,需要扔蛋的最少次数。
: 刚才看答案了,可是不理解f(i,j-w)是什么意思,哪来的j-w??
: 答案说:f(i,j)表示i个蛋在j层楼上最坏情况下确定x需要的最少次数。
: f(i,j) = min{max{f(i-1,w-1),f(i,j-w)}+1} w是层数
: 哪位高手出来用通俗的语言解释一下这个答案呢?? 先谢了:-)
f(i,j) = min { |
2009-02-09 22:32
Jack has bought a rectangular table containing a grid of lamps. Each lamp is initially either "on" or "off". There is a switch underneath each column, and when the switch is flipped, all the lamps in that column reverse their states ("on" lamps become "off" and vice versa).
A row in the grid is considered lit if all the lamps in that row are "on". Jack must make exactly K flips. The K flips do n |
2008-11-23 00:48
SRM423d1
Two players play a simple game on a n x n board. The first player has a single white checker which is initially located at (rowWhite, colWhite). The second player has a single black checker which is initially located at (rowBlack, colBlack). All coordinates are 1-based. The two players alternate turns, and the first player moves first.
When it is the first p |
2008-11-22 20:00
所谓曼哈顿距离:
假设点A的坐标为x0,y0, 点B的坐标为x1,y1
那么A和B的曼哈顿距离为: abs(x0-x1)+abs(y0-y1).
现在有这样一个题目:
平面上有n个点,给出他们坐标(可能有多个点的坐标是一样的)。 一次操作可以将一个点上移、下移、左移或者右移一个单位。
现在需要平面上某个坐标上至少有k个点,问需要最好的操作次数?
solution:
Let's fix some K and try to find the best way to gather some K checkers in the same cell. To do this, we first consider a very slow approach: i |
2008-11-15 17:35
There are N trees numbered 0 to N-1, and you must plant them along a straight line. Tree i will be planted at coordinate X[i], where X is constructed using the following recursive definition:
X[0] = X0 MOD L
X[i] = (X[i-1]*A+B) MOD L (note that X[i-1]*A+B may overflow a 32-bit integer)
The price of planting tree i is the sum of the |
2008-10-19 23:37
过桥问题。 一堆人要过桥,只有一个手电筒,桥本身有最大载重。给出每个人的重量,给出每个人过桥需要的时间。一组人过桥,时间按速度最慢的算。过桥的时候必须使用手电筒。这个相对来说很常见了。现在题目又给出了任意两个人之间的信任关系,要求一组人过桥的时候,每个人至少信任组内另外一个人。当然也可以一个人单独过桥。
问所有人过桥的最短时间。
这个题目典型的宽搜,但是需要注意的是,从桥的对面回来(把手电筒带回来)时,可能最优情况需要不止一个人回来。原因是题目中加上了信任模型。
srm422 d1 level2. |
2008-10-06 20:07
经典著作《人工智能:现代方法》的作者之一 Peter Norvig 曾经写过一篇介绍如何写一个拼写检查/纠正器的文章(原文在这里,徐宥的翻译版在这里,这篇文章很深入浅出,强烈建议读一读),里面用到的就是贝叶斯方法--- by ponda.
也可以看看ponda老大写的这篇文章。 |
2008-10-06 20:01
|
|
|