Hangover
Time Limit: 1000MS |
Memory Limit: 10000K |
Total Submissions: 106593 |
Accepted: 51987 |
Description
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 cardlength.
如果你有一張卡片,你最多能使卡片長度的一半伸出桌子。
(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 acard length,
如果有兩張卡片,你最多能使上面一張卡片的1/2超出下面一張卡片
and the bottom one overhang thetable by a third of a card length,
下面一張卡片的1/3伸出桌子
for a total maximum overhang of 1/2 + 1/3 = 5/6 cardlengths.
總共伸出桌子的長度是1/2 + 1/3 = 5/6個卡片長度
In general you can make n cards overhang by 1/2 + 1/3 + 1/4 + ... +1/(n + 1) cardlengths,
總之,你可以使n張卡片的1/2 + 1/3 + 1/4 + ... +1/(n + 1)長度伸出桌子
where the top card overhangs the second by 1/2,
最上一張卡片伸出1/2
the second overhangs tha third by 1/3,
第二張伸出1/3
the third overhangs the fourth by1/4, etc.,
第三張伸出1/4
and the bottom card overhangs the table by 1/(n + 1).
最下面一張伸出1/(n + 1)
This is illustrated in the figure below.
如下圖所示
Input
The inputconsists of one or more test cases,
輸入包含多組測試數據
followed by aline containing the number 0.00 that signals the end of the input.
0.00表示輸入結束
Each test case is a single line containing apositive floating-point number c whose value is at least 0.01 and at most 5.20;
每組測試佔一行,包含一個0.01到 5.20之間的小數c
c willcontain exactly three digits.
c恰好是一個三位數
Output
For each testcase, output the minimum number of cards necessary to achieve an overhang of atleast c card lengths.
對於每組測試,輸出伸出長度c最少需要的卡片數量
Use the exact output format shown in theexamples.
用精確的數輸出。
Sample Input
1.00
3.71
0.04
5.19
0.00
Sample Output
3card(s)
61card(s)
1card(s)
273card(s)
Source