博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Hangover POJ - 1003
阅读量:5225 次
发布时间:2019-06-14

本文共 1714 字,大约阅读时间需要 5 分钟。

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

Sample Output

3 card(s)61 card(s)1 card(s)273 card(s)

解题思路:水题。

1 #include 
2 #include
3 #include
4 5 using namespace std; 6 7 int main() 8 { 9 double a;10 int countt=0;11 double now=0;12 double sum=0;13 while(scanf("%lf",&a)&&(fabs(a-0)>0.0001)){14 sum=0;15 now=0;16 countt=1;17 while(sum
View Code

 

转载于:https://www.cnblogs.com/TWS-YIFEI/p/9110064.html

你可能感兴趣的文章
转摘:ashx+jquery-autocomplete文本框输入提示功能Asp.net
查看>>
C#找出第n到m个素数之间所有之和
查看>>
String常用方法简介
查看>>
java 字符串大小比较
查看>>
接收会计事件表和接收会计分录表
查看>>
Prototype源码浅析——Hash部分(一)
查看>>
幼谈苹果新开发语言:Swift和苹果的用心
查看>>
ACM-ICPC国际大学生程序设计竞赛北京赛区(2017)网络赛 A题 Visiting Peking University...
查看>>
剑灵-控制技能图及武器升级图
查看>>
Bean自动装配-XML最小化配置
查看>>
rewrap-ajax.js插件
查看>>
Python之Split函数
查看>>
Linux下使用pip安装keras
查看>>
OpenCv-Python 图像处理基本操作
查看>>
博物院与国宝
查看>>
vmware tools 的安装(Read-only file system 的解决)
查看>>
数列求和总结
查看>>
「Unity」委托 将方法作为参数传递
查看>>
Unity学习疑问记录之隐藏与显示物体
查看>>
设计模式-学习
查看>>