Hangover

时间限制: 1000ms 内存限制: 65536KB

问题描述

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

样例输入
1.00
3.71
0.04
5.19
0.00

样例输出
3 card(s)
61 card(s)
1 card(s)
273 card(s)

来源
{Mid-Central USA 2001}

问题分析:(略)

这个问题和《POJ1003 UVALive2294 HDU1056 ZOJ1045 Hangover【数学计算】》是同一个问题,代码拿过来用就AC了。

程序说明:参见参考链接。

参考链接:POJ1003 UVALive2294 HDU1056 ZOJ1045 Hangover【数学计算】

题记:程序做多了,不定哪天遇见似曾相识的。

AC的C++程序如下:

/* POJ1003 UVALive2294 HDU1056 ZOJ1045 Hangover */  #include <iostream>
#include <cstdio>  using namespace std;  const double one = 1.0;  int main()
{  double len, sum, d;  int i;  while((cin >> len) && len != 0.00) {  i = 1;  d = 2.0;  sum = one / d;  while(sum < len) {  d += 1.0;  sum += (one / d);  i++;  }  cout << i << " card(s)" << endl;  }  return 0;
} 

NUC1003 Hangover【数学计算+水题】相关推荐

  1. NUC1011 Financial Management【数学计算+水题】

    Financial Management 时间限制: 1000ms 内存限制: 10000KB 问题描述 Larry graduated this year and finally has a job ...

  2. HDU3782 xxx定律【数学计算+水题】

    xxx定律 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Subm ...

  3. HDU2551 竹青遍野【数学计算+水题】

    竹青遍野 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submi ...

  4. HDU2178 猜数字【数学计算+水题】

    猜数字 Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submis ...

  5. HDU2156 分数矩阵【数学计算+水题】

    分数矩阵 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submi ...

  6. HDU2153 仙人球的残影【数学计算+水题】

    仙人球的残影 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Sub ...

  7. HDU2548 两军交锋【数学计算+水题】

    两军交锋 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submi ...

  8. 数学题库python_GitHub Python项目推荐|一个拍照做题程序|数学计算题识题|opencv...

    GitHub Python项目推荐|一个拍照做题程序输入一张包含数学计算题的图片输出识别出的数学计算式以及计算结果 项目分析 仓库名称:mathAI 标星(star):1469 (网红级项目,高手作品 ...

  9. [蓝桥杯2018初赛]第几天-日期计算(水题)

    闰年(Leap Year)是为了弥补因人为历法规定造成的年度天数与地球实际公转周期的时间差而设立的.补上时间差的年份为闰年.闰年共有366天(1月~12月分别为31天.29天.31天.30天.31天. ...

最新文章

  1. 洛谷P2429 制杖题 [2017年6月计划 数论10]
  2. 字符串中包含汉字和\u,显示出汉字来
  3. JZOJ 5377. 【NOIP2017提高A组模拟9.19】开拓
  4. 2019 AI Bootcamp·Guangzhou 参会日记
  5. Mysql学习总结(58)——深入理解Mysql的四种隔离级别
  6. Starling 动画功能
  7. [C#-Util]-读写文件汉字乱码
  8. 我想创业,但不懂技术怎么办
  9. ITIL4培训系列之变更支持流程和实践讲解
  10. win7计算机锁频图片怎么设置,win7锁屏背景壁纸如何修改
  11. 动漫测试题软件,Flash动画考试试卷
  12. repaire mysql_sql错误:……is marked as crashed and should be repaire
  13. coreldraw做生化标志_CorelDRAW标志绘制图文教程,logo设计制作教程
  14. php 随机经纬度,使用php,API自动获取经纬度
  15. 2017到2018总结与展望
  16. 视网膜正常oct图_眼科泰斗经验分享:OCT检查图像采集及解读分析(非常值得收藏)...
  17. 在SQLBolt网站上学习入门SQL
  18. softmax溢出问题
  19. cgb2108-day02
  20. 关于自动生成数据集的一些事

热门文章

  1. ArcGIS Desktop 10.5 安装实录
  2. ndr4108贴片晶振是多少频率_流处理器、核心频率、 位宽……这些显卡参数你知道吗?—— 电脑硬件科普篇(八)...
  3. java 监听端口_java游戏服务器检查报告(经验分享)
  4. canvas换图时候会闪烁_基于Canvas实现的高斯模糊(上)「JS篇」
  5. Jmeter使用方法
  6. 学习java第二天 java体系结构与表面执行流程 (one 大白(●—●))
  7. java8 方法引用详解_Java8中如何通过方法引用获取属性名详解
  8. php curl修改ip,php中curl设置ip的方法
  9. linux去掉日志中的skipping,Linux日志文件总管 logrotate
  10. pythoncopy函数_Python的shutil模块中文件的复制操作函数详解