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



Input

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.

Output

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.

Sample Input

1.00
3.71
0.04
5.19
0.00

Sample Output

3 card(s)
61 card(s)
1 card(s)
273 card(s)
#include <iostream>
#include<cmath>
using namespace std;
int main()
{
double t[10000];
t[0]=0;
int i=0;
for(;t[i]<=5.2;)
{
i++;
t[i]=t[i-1]+1.00/(i+1);
}
double x;
while(cin>>x&&x)
{
int l, r;
l = 0;
r = i ;
while (l + 1 < r)
{
int mid = (l + r) / 2;
if ((t[mid] - x)<-0.0000001)
l = mid;
else
r = mid;
}
cout << r << " card(s)" << endl; } return 0;
}

E - Hangover(1.4.1)的更多相关文章

  1. poj 1003:Hangover(水题,数学模拟)

    Hangover Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 99450   Accepted: 48213 Descri ...

  2. Hangover[POJ1003]

    Hangover Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 121079   Accepted: 59223 Descr ...

  3. [POJ1003]Hangover

    [POJ1003]Hangover 试题描述 How far can you make a stack of cards overhang a table? If you have one card, ...

  4. HangOver

    HangOver Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Su ...

  5. Hangover 分类: POJ 2015-06-11 10:34 12人阅读 评论(0) 收藏

    Hangover Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 108765   Accepted: 53009 Descr ...

  6. HDU1056 HangOver

    HangOver Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u   Descript ...

  7. [POJ] #1003# Hangover : 浮点数运算

    一. 题目 Hangover Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 116593   Accepted: 56886 ...

  8. OpenJudge / Poj 1003 Hangover

    链接地址: Poj:http://poj.org/problem?id=1003 OpenJudge:http://bailian.openjudge.cn/practice/1003 题目: Han ...

  9. POJ1003 – Hangover (基础)

    Hangover   Description How far can you make a stack of cards overhang a table? If you have one card, ...

  10. 快速切题 poj 1003 hangover 数学观察 难度:0

    Hangover Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 103896   Accepted: 50542 Descr ...

随机推荐

  1. django自定义signal的发送和接收样例

    想在项目中用上,就实习一下. # coding:utf8 from django.dispatch import Signal from django.dispatch import receiver ...

  2. MVC5 ModelState

    ModelState.IsValid 总是false的原因 在做添加功能的时候,发现这个IsValid总是false,这个是它自己的验证机制. 因为是添加,就是说主键是自增的,添加的时候不需要指定这个 ...

  3. (6)sql/puls

    host   在sql/puls中使用cmd或linux操作系统的命令

  4. 几何【P2313】 [HNOI2005]汤姆的游戏

    顾z 你没有发现两个字里的blog都不一样嘛 qwq 题目描述--->p2313 [HNOI]汤姆的游戏 分析 说不上是分析. 数据范围给出来,这题明显暴力啊emmm. 个人认为的坑点. 这题不 ...

  5. POJ 2441 Arrange the Bulls(状压DP)

    [题目链接] http://poj.org/problem?id=2441 [题目大意] 每个人有过个喜欢的篮球场地,但是一个场地只能给一个人, 问所有人都有自己喜欢的场地的方案数. [题解] 状态S ...

  6. [51Nod1487]占领资源

    题目大意:​ 有一个$n\times m(x,m\leq 100)$的网格图,每个格子有一个权值$w_{i,j}(1\leq w_{i,j}\leq 9)$.你可以在图中选两个格子,每个格子$(x,y ...

  7. PHP缩略图类

    class ThumbImages{ /** * 生成缩略图 * prorate 按比例缩放 * distortion 扭曲型缩图 * cut 最小裁剪后的缩图 * backFill 背景填充图 * ...

  8. 微软官方的精简版Windows 7——Windows Thin PC

    Windows Thin PC是微软的Window 7的精简版本,它的一个非常明显的特点是系统资源占用小.如下是官方的系统配置需求: CPU:    主频1 GHz 内存:    1GB(实际占用约5 ...

  9. 如何命令行编译Java工程

    在src下的包含Main的包下打开命令行,javac -classpath “路径到src,不到包下”  Main.java

  10. threadlocal彻底理解

    如果你定义了一个单实例的java bean,它有若干属性,但是有一个属性不是线程安全的,比如说HashMap.并且碰巧你并不需要在不同的线程中共享这个属性,也就是说这个属性不存在跨线程的意义.那么你不 ...