# NYOJ 156 Hangover

## 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.003.710.045.190.00

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

POJ

iphxer
#include<stdio.h>
int main()
{
double sum;
while(~scanf("%lf",&sum),sum)
{
double s=0,a=0;
while(sum>s)
{
s+=1/(2+a);
a++;
}
printf("%.lf card(s)\n",a);
}
return 0;
}


• 本文已收录于以下专栏：

## NYoj 156 Hangover

Hangover 时间限制：1000 ms | 内存限制：65535 KB 难度：1 描述 How far can you make a stack of cards overhang a...
• iamldy
• 2017年05月17日 11:33
• 220

## NYOJ 156 Hangover

Hangover 时间限制：1000 ms  |  内存限制：65535 KB 难度：1 描述 How far can you make a stack of cards overhang...
• LiuJiuXiaoShiTou
• 2017年07月22日 20:20
• 160

## poj 1003 （nyoj 156） Hangover

• a27985649
• 2013年09月10日 21:24
• 586

## poj 1003&&HDU 1056 && nyoj 156 Hangover【水题】

Hangover 时间限制：1000 ms  |  内存限制：65535 KB 难度：1 描述 How far can you make a stack of cards overhang a ta...
• liuke19950717
• 2015年09月10日 23:10
• 351

## NYOJ - Hangover

Hangover 时间限制：1000 ms  |           内存限制：65535 KB 难度：1 描述 How far can you make a stack of cards ...
• SevenMIT
• 2012年11月05日 18:01
• 279

## HDU 1056.HangOver【水！水！水！】【8月28】

HangOver Problem Description How far can you make a stack of cards overhang a table? If you ...
• a995549572
• 2015年08月28日 17:56
• 438

## HDU HangOver

• u011481047
• 2016年03月16日 17:17
• 153

## hdu1056HangOver

HangOver Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total...
• sungaochao
• 2014年11月30日 20:43
• 533

## FZU 1002 HangOver（简单题目）

• qq_32866009
• 2016年03月06日 22:49
• 408

## 杭电1056——HangOver（水题）

Problem Description How far can you make a stack of cards overhang a table? If you have one card, y...
• qianchangdiyin
• 2016年01月22日 16:37
• 590

举报原因： 您举报文章：NYOJ 156 Hangover 色情 政治 抄袭 广告 招聘 骂人 其他 (最多只允许输入30个字)