hdu_1056_HangOver_201311071354
2024-09-29 22:41:58
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.
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 ;
}
简单题,按题中给的公式来就行
最新文章
- Data Validate 之 Data Annotation
- set集合(set是一个无序且不重复的元素集合)
- codeforces480E Parking Lot
- 【Stirling Number I】
- Weka 入门1
- 垃圾回收GC——JVM之七
- poj 1328 Radar Installation_贪心
- 如何隐藏DLL中,导出函数的名称?(转)
- 360提供的php防注入代码
- js 控制随机数生成概率
- FPGA中带优先级的if else if与不带优先级的case的探讨
- (转)Spring Boot(六):如何优雅的使用 Mybatis
- python--编写用例脚本
- 【译】第十篇 SQL Server安全行级安全
- 实验吧 ASCII艺术
- @RemoteProxy()注释 与@File注释的使用
- glide使用
- 漫画 | Spring AOP
- mysql主备切换[高可用]
- ABP学习入门系列(五)(展示实现增删改查)
热门文章
- MSXML2.XMLHTTP.4.0对象
- 过河 2005年NOIP全国联赛提高组(离散化+dp)
- selenium3 + python - 异常处理截图 screenshot
- RocketMQ(1)--helloworld
- Netty--数据通信和心跳检测
- C#学习-图片的处理
- css3通过scale()实现放大功能、通过rotate()实现旋转功能
- Android studio USB连接失败
- Html test
- 宏基因组扩增子图表解读2散点图:组间整体差异分析(Beta多样性)