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 ;
}

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

最新文章

  1. Data Validate 之 Data Annotation
  2. set集合(set是一个无序且不重复的元素集合)
  3. codeforces480E Parking Lot
  4. 【Stirling Number I】
  5. Weka 入门1
  6. 垃圾回收GC——JVM之七
  7. poj 1328 Radar Installation_贪心
  8. 如何隐藏DLL中,导出函数的名称?(转)
  9. 360提供的php防注入代码
  10. js 控制随机数生成概率
  11. FPGA中带优先级的if else if与不带优先级的case的探讨
  12. (转)Spring Boot(六):如何优雅的使用 Mybatis
  13. python--编写用例脚本
  14. 【译】第十篇 SQL Server安全行级安全
  15. 实验吧 ASCII艺术
  16. @RemoteProxy()注释 与@File注释的使用
  17. glide使用
  18. 漫画 | Spring AOP
  19. mysql主备切换[高可用]
  20. ABP学习入门系列(五)(展示实现增删改查)

热门文章

  1. MSXML2.XMLHTTP.4.0对象
  2. 过河 2005年NOIP全国联赛提高组(离散化+dp)
  3. selenium3 + python - 异常处理截图 screenshot
  4. RocketMQ(1)--helloworld
  5. Netty--数据通信和心跳检测
  6. C#学习-图片的处理
  7. css3通过scale()实现放大功能、通过rotate()实现旋转功能
  8. Android studio USB连接失败
  9. Html test
  10. 宏基因组扩增子图表解读2散点图:组间整体差异分析(Beta多样性)