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

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>
#define exp 1e-6
using namespace std;
double sum[300];
int main()
{
sum[0]=0;
for(int i=1;i<=300; i++)
{
sum[i]=(1.0/(i+1))+sum[i-1];
}
double len;
while(cin>>len)
{
if(len<exp)
{
break;
}
for(int i=1;i<=300;i++)
{
if(len<sum[i])
{
cout<<i<<" card(s)"<<endl;
break;
} } }
return 0;
}

版权声明:本文为博主原创文章,未经博主允许不得转载。

Hangover 分类: POJ 2015-06-11 10:34 12人阅读 评论(0) 收藏的更多相关文章

  1. 山东理工大学第七届ACM校赛-经济节约 分类: 比赛 2015-06-26 10:34 19人阅读 评论(0) 收藏

    经济节约 Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述 由于经济紧张,某国国王决定减少一部分多余的士兵,这些士兵在边界都有各自的 ...

  2. Financial Management 分类: POJ 2015-06-11 10:51 12人阅读 评论(0) 收藏

    Financial Management Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 164431   Accepted: ...

  3. The Pilots Brothers' refrigerator 分类: POJ 2015-06-15 19:34 12人阅读 评论(0) 收藏

    The Pilots Brothers' refrigerator Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 20304 ...

  4. IP Address 分类: POJ 2015-06-12 19:34 12人阅读 评论(0) 收藏

    IP Address Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 19125   Accepted: 11053 Desc ...

  5. Poj 1029 分类: Translation Mode 2014-04-04 10:18 112人阅读 评论(0) 收藏

    False coin Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 16418   Accepted: 4583 Descr ...

  6. 博弈论入门小结 分类: ACM TYPE 2014-08-31 10:15 73人阅读 评论(0) 收藏

    文章原地址:http://blog.csdn.net/zhangxiang0125/article/details/6174639 博弈论:是二人或多人在平等的对局中各自利用对方的策略变换自己的对抗策 ...

  7. C#中的线程(上)-入门 分类: C# 线程 2015-03-09 10:56 53人阅读 评论(0) 收藏

    1.     概述与概念 C#支持通过多线程并行地执行代码,一个线程有它独立的执行路径,能够与其它的线程同时地运行.一个C#程序开始于一个单线程,这个单线程是被CLR和操作系统(也称为"主线 ...

  8. C#多线程(下) 分类: C# 线程 2015-03-09 10:41 153人阅读 评论(0) 收藏

    四.多线程的自动管理(线程池) 在多线程的程序中,经常会出现两种情况: 一种情况: 应用程序中,线程把大部分的时间花费在等待状态,等待某个事件发生,然后才能给予响应 这一般使用ThreadPool(线 ...

  9. iOS开发:创建真机调试证书 分类: ios相关 2015-04-10 10:22 149人阅读 评论(0) 收藏

    关于苹果iOS开发,笔者也是从小白过来的,经历过各种困难和坑,其中就有关于开发证书,生产证书,in_house证书,add_Hoc证书申请过程中的问题,以及上架发布问题.今天就着重说一下关于针对于苹果 ...

随机推荐

  1. decimal类型保留两位小数

    oj.PriceTop =Math.Round(Convert.ToDecimal(reader["PriceTop"]),2);

  2. 转:python webdriver API 之控制浏览器滚动条

    有时候 web 页面上的元素并非直接可见的,就算把浏览器最大化,我们依然需要拖动滚动条才能看到想要操作的元素, 这个时候就要控制页面滚动条的拖动, 但滚动条并非页面上的元素, 可以借助 JavaScr ...

  3. .net开发,html ajax开发架构之我见 bs ajax最简化法 Knock out Request,totally oo

    .net开发中,无论ajax还是webform,webpage, 总免不了要和request这个静态全局,可以远程通信的对象打交道. 而对于软件来讲,按照Matin Fowler的的面向对象,可利用软 ...

  4. windows系统调用 进程终止

    #include "windows.h" #include "iostream" #include "stdio.h" using name ...

  5. zw版【转发·台湾nvp系列Delphi例程】HALCON SmoothImage

    zw版[转发·台湾nvp系列Delphi例程]HALCON SmoothImage procedure TForm1.Button1Click(Sender: TObject);var image0, ...

  6. php file_get_contents与curl性能比较

    1.fopen /file_get_contents 每次请求都会重新做DNS查询,并不对 DNS信息进行缓存.但是CURL会自动对DNS信息进行缓存.对同一域名下的网页或者图片的请求只需要一次DNS ...

  7. 图像处理之常用颜色RGB、灰度值

    128/0/0       深红         255/0/0       红           255/0/255     粉红        255/153/204 玫瑰红       153 ...

  8. error CS0007: Unexpected common language runtime initialization error -- '没有注册类别 '

    Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework]"Inst ...

  9. SDK Manager failed to install 'java.exe' locking directory

    转自:http://stackoverflow.com/questions/13587478/sdk-manager-failed-to-install-java-exe-locking-direct ...

  10. 【secureCRT】中文乱码问题

    Options->Session Options->Appearance->Font->新宋体 字符集:中文GB2312 ->Character encoding 为UT ...