HangOver

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 8258    Accepted Submission(s): 3414

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

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.
 
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)
 
 
Source
 
 
 #include <stdio.h>

 int main()
{
double n;
while(scanf("%lf",&n),n)
{
int i;
double sum=;
i=;
while(sum<n)
{
i++;
sum+=1.0/(i+);
}
printf("%d card(s)\n",i);
}
return ;
}

简单题,按题中给的公式来就行

hdu_1056_HangOver_201311071354的更多相关文章

随机推荐

  1. js 获取URL的值

    今天碰到要在一个页面获取另外一个页面url传过来的参数,一开始很本能的想到了用 split("?")这样一步步的分解出需要的参数. 后来想了一下,肯定会有更加简单的方法的!所以在网 ...

  2. ACM_小G的循环

    小G的循环 Time Limit: 2000/1000ms (Java/Others) Problem Description: 一回生,二回熟,三回就腻,小G用for,while循环用得太多了,累觉 ...

  3. Mysql中timestamp用法详解

    前言:时间戳(timestamp),一个能表示一份数据在某个特定时间之前已经存在的. 完整的. 可验证的数据,通常是一个字符序列,唯一地标识某一刻的时间.使用数字签名技术产生的数据, 签名的对象包括了 ...

  4. <stddef.h>

    Common definitions 定义类型: ptrdiff_t 两指针相减的结果,signed integer size_t sizeof操作符的结果,unsigned integer max_ ...

  5. js加减乘除在线计算器代码

    js加减乘除在线计算器代码 在线演示本地下载

  6. 笔记《精通css》第5章 链接应用样式

    第5章    链接应用样式 1.链接伪类选择器 a : link{    }   (寻找没有被访问过的链接) a : visied{    }(寻找被访问过的链接) 动态伪类选择器 a : hover ...

  7. Hive扩展功能(七)--Hive On Spark

    软件环境: linux系统: CentOS6.7 Hadoop版本: 2.6.5 zookeeper版本: 3.4.8 主机配置: 一共m1, m2, m3这五部机, 每部主机的用户名都为centos ...

  8. Hive扩展功能(四)--HiveServer2服务

    软件环境: linux系统: CentOS6.7 Hadoop版本: 2.6.5 zookeeper版本: 3.4.8 主机配置: 一共m1, m2, m3这五部机, 每部主机的用户名都为centos ...

  9. html5——3D案例(立方体)

    立方体:父盒子规定了3d呈现属性,立方体做旋转运动 移动顺序:1.每个盒子都先移动100px,然后再做相应的旋转  2.只有这样立方体的几何中心点与父盒子的几何中心点是一样的 <!DOCTYPE ...

  10. cmd 启动mysql环境变量配置

    win10系统:(其他系统类似,改环境变量就可以) 1.我的电脑,右键选择属性,进入系统页面 2.点击高级系统设置,进入系统属性页面 3.点击高级选项卡,点击环境变量,进入环境变量设置 4.选择系统变 ...