2013
11-28

# HangOver

How far can you make a stack of cards overhang a table? If you have one card, you can create a maximum overhang of half a card length. (We’re assuming that the cards must be perpendicular to the table.) With two cards you can make the top card overhang the bottom one by half a card length, and the bottom one overhang the table by a third of a card length, for a total maximum overhang of 1/2 + 1/3 = 5/6 card lengths. In general you can make n cards overhang by 1/2 + 1/3 + 1/4 + … + 1/(n + 1) card lengths, where the top card overhangs the second by 1/2, the second overhangs tha third by 1/3, the third overhangs the fourth by 1/4, etc., and the bottom card overhangs the table by 1/(n + 1). This is illustrated in the figure below.

The input consists of one or more test cases, followed by a line containing the number 0.00 that signals the end of the input. Each test case is a single line containing a positive floating-point number c whose value is at least 0.01 and at most 5.20; c will contain exactly three digits.

For each test case, output the minimum number of cards necessary to achieve an overhang of at least c card lengths. Use the exact output format shown in the examples.

1.00
3.71
0.04
5.19
0.00

3 card(s)
61 card(s)
1 card(s)
273 card(s)

#include<stdio.h>
double s,n;
int c;
main()
{
while(scanf("%lf",&n)==1&&n>0)
{
for(c=1,s=0.5;s<n;c++)
s+=(1.0/(c+2));
printf("%d card(s)\n",c);
}
}

1. 我不知道这部电影如何，但我知道饥饿游戏，不管是1，还是2，还是3，都是没有任何新意，没有任何欣赏价值的电影。我很奇怪，为何这种脑残饥饿游戏还能出来这么多，而且喜欢的人也这么多。我实在无法任何未来的样子是那种被一帮所谓精英阶层控制，社会被他们像玩过家家一样

2. 学算法中的数据结构学到一定程度会乐此不疲的，比如其中的2－3树，类似的红黑树，我甚至可以自己写个逻辑文件系统结构来。

3. 如果两个序列的最后字符不匹配（即X [M-1]！= Y [N-1]）
L（X [0 .. M-1]，Y [0 .. N-1]）= MAX（L（X [0 .. M-2]，Y [0 .. N-1]），L（X [0 .. M-1]，Y [0 .. N-1]）
这里写错了吧。

4. Gucci New Fall Arrivals

This is really nice to know. I hope it will be successful in the future. Good job on this and keep up the good work.

5. 可以参考算法导论中的时间戳。就是结束访问时间，最后结束的顶点肯定是入度为0的顶点，因为DFS要回溯