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.00
3.71
0.04
5.19
0.00

Sample Output

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

解题思路:水题。

 #include <iostream>
#include <cstdio>
#include <cmath> using namespace std; int main()
{
double a;
int countt=;
double now=;
double sum=;
while(scanf("%lf",&a)&&(fabs(a-)>0.0001)){
sum=;
now=;
countt=;
while(sum<a){
countt++;
sum+=1.0/countt;
}
printf("%d card(s)\n",countt-);
}
return ;
}

Hangover POJ - 1003的更多相关文章

  1. POJ.1003 Hangover ( 水 )

    POJ.1003 Hangover ( 水 ) 代码总览 #include <cstdio> #include <cstring> #include <algorithm ...

  2. OpenJudge / Poj 1003 Hangover

    链接地址: Poj:http://poj.org/problem?id=1003 OpenJudge:http://bailian.openjudge.cn/practice/1003 题目: Han ...

  3. [POJ 1003] Hangover C++解题

        Hangover Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 95164   Accepted: 46128 De ...

  4. poj 1003:Hangover(水题,数学模拟)

    Hangover Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 99450   Accepted: 48213 Descri ...

  5. [POJ] #1003# Hangover : 浮点数运算

    一. 题目 Hangover Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 116593   Accepted: 56886 ...

  6. 快速切题 poj 1003 hangover 数学观察 难度:0

    Hangover Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 103896   Accepted: 50542 Descr ...

  7. POJ 1003:Hangover

    Hangover Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 109231   Accepted: 53249 Descr ...

  8. poj 1003 (nyoj 156) Hangover

    点击打开链接 题目大意 就是有很多卡片可以沿着桌边向外放,每次可以伸出1/2,1/3,1/4问最少多少卡片才能让一张完成的卡片悬空,题目输入卡片的宽度,输出卡片个数 #include<stdio ...

  9. poj 1003 Hangover

    #include <iostream> using namespace std; int main() { double len; while(cin >> len & ...

随机推荐

  1. 解决 IIS 反向代理ARR URLREWRITE 设置后,不能跨域跳转 return Redirect 问题

    1.选择iis根节点,点击ARR 2.选择代理设置 3.去掉reverse rewrite host in response headers的勾选,点击应用即可

  2. WebService - [Debug] java.net.BindException: Can't assign requested address

    Connected to the target VM, address: '127.0.0.1:57803', transport: 'socket' Exception in thread &quo ...

  3. Java基础7-异常;jar包

    昨日内容回顾 多态:多种状态,多态的前提条件是继承或者是实现 面向接口编程 降低耦合度 接口是最低标准,接口可以多重继承 接口中的所有方法都是抽象方法 抽象类中可以没有抽象方法 匿名内部类对象 将对类 ...

  4. Mysql -- 数据类型(2)

    掌握char类型和varchar类型 掌握枚举类型和集合类型 字符类型 #官网:https://dev.mysql.com/doc/refman/5.7/en/char.html #注意:char和v ...

  5. vue.js组件命名

  6. [Linux]ln -al输出内容解析

    第一项的第一位是文件类型:-: 表示普通文件d: 目录b: 块特殊文件c: 字符特殊文件l:  符号链接文件p: 命名管道文件FIFOs: 套接字文件 第二项是该文件的inode的链接计数,即stat ...

  7. 洛谷P3348 [ZJOI2016]大森林 [LCT]

    传送门 刷了那么久水题之后终于有一题可以来写写博客了. 但是这题太神仙了我还没完全弄懂-- upd:写完博客之后似乎懂了. 思路 首先很容易想到\(O(n^2\log n)\)乘上\(O(\frac{ ...

  8. 用什么方法给PDF添加页眉页脚

    我们所看到的书本中都会设置好有页眉页脚,那么电子书想要添加页眉页脚要怎么操作呢,用什么方法可以在PDF中添加页眉页脚呢,今天就为大家分享一下,如何在电子文件中添加页眉页脚,想知道的小伙伴们就一起来看看 ...

  9. C++中几个输入函数的用法和区别(cin、cin.get()、cin.getline()、getline()、gets()、getchar())

    1.cin>> 用法1:最基本,也是最常用的用法,输入一个数字: #include <iostream>using namespace std;main (){int a,b; ...

  10. Mac 桌面软件开发基础问答

    1> Mac OS X平台下的桌面软件是由什么编程语言处理 答: 由Objective-C, swift编程语言处理 2> Mac OS X平台下的桌面软件是由什么框架构建 答: 由Coc ...