NYOJ 156 Hangover

原创 2013年12月03日 14:12:38

Hangover

时间限制:1000 ms  |  内存限制:65535 KB
难度:1
描述

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
  • 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
  • LiuJiuXiaoShiTou
  • 2017年07月22日 20:20
  • 160

poj 1003 (nyoj 156) Hangover

点击打开链接 题目大意 就是有很多卡片可以沿着桌边向外放,每次可以伸出1/2,1/3,1/4问最少多少卡片才能让一张完成的卡片悬空,题目输入卡片的宽度,输出卡片个数 #include int ar...
  • a27985649
  • 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
  • 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
  • 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
  • a995549572
  • 2015年08月28日 17:56
  • 438

HDU HangOver

本题传送门:http://acm.hdu.edu.cn/showproblem.php?pid=1056 英文阅读理解题,六级难度。#include #include //#define LOCAL...
  • u011481047
  • 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
  • sungaochao
  • 2014年11月30日 20:43
  • 533

FZU 1002 HangOver(简单题目)

题目网址:http://acm.fzu.edu.cn/problem.php?pid=1002本题真的很简单,没什么好说的,直接附上AC代码。#includeint main() { doub...
  • qq_32866009
  • 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
  • qianchangdiyin
  • 2016年01月22日 16:37
  • 590
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:NYOJ 156 Hangover
举报原因:
原因补充:

(最多只允许输入30个字)