Hangover
Time Limit: 1000MS   Memory Limit: 10000K
Total Submissions: 121079   Accepted: 59223

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.

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 <stdio.h>
#include <algorithm>
#include <math.h>
using namespace std;
#define eps 1e-8
int main() {
double a, s;
while (scanf("%lf", &a) != EOF) {
if (a < eps) {
break;
}
s = ;
for (int i = ;; i++) {
s += 1.0 / (double)i;
if (s - a > eps) {
printf("%d card(s)\n", i - );
break;
}
}
}
return ;
}
 

Hangover[POJ1003]的更多相关文章

  1. [POJ1003]Hangover

    [POJ1003]Hangover 试题描述 How far can you make a stack of cards overhang a table? If you have one card, ...

  2. POJ1003 – Hangover (基础)

    Hangover   Description How far can you make a stack of cards overhang a table? If you have one card, ...

  3. 【POJ1003】Hangover(二分搜索)

    直接用库函数二分即可. #include <iostream> #include <cstring> #include <cstdlib> #include < ...

  4. POJ-1003&1004

    这两题比较简单,就不做分析了,描述下题目,就上代码吧. [题目描述] 1003,其实就是求这个方程的最小n:1/2 + 1/3 + 1/4 + ... + 1/(n + 1) >= c: 100 ...

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

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

  6. HangOver

    HangOver Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Su ...

  7. Hangover 分类: POJ 2015-06-11 10:34 12人阅读 评论(0) 收藏

    Hangover Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 108765   Accepted: 53009 Descr ...

  8. HDU1056 HangOver

    HangOver Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u   Descript ...

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

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

随机推荐

  1. [译] 用 Swift 创建自定义的键盘

    本文翻译自 How to make a custom keyboard in iOS 8 using Swift 我将讲解一些关于键盘扩展的基本知识,然后使用iOS 8 提供的新应用扩展API来创建一 ...

  2. C#的LINQ to Object

    using System; using System.Collections; using System.Collections.Generic; using System.IO; using Sys ...

  3. HTML学习之Web存储(五)

    本地数据库功能大大增强了Web应用对于本地存储数据的方式和功能.Web时代真正进入了:“客户端为重,服务端为轻的时代”. <!DOCTYPE html> <html xmlns=&q ...

  4. 【转载】pyqt QTableWidget的使用

    转载地址: http://blog.sina.com.cn/s/blog_9b78c91101019sgi.html QTableWidget是QT程序中常用的显示数据表格的空间,很类似于VC.C#中 ...

  5. 【JAVA之泛型】

    一.引例. 1.引例. 假设现在有一个ArrayList的容器,如果不使用泛型约束,则可以向容器中加入各种类型的对象,但是如果取出来的时候只是用一种类型的转换则肯定会抛出ClassCastExcept ...

  6. angularJS 二

    angularJS 2.1  ngForm <!DOCTYPE html> <html lang="zh-cn" ng-app> <head> ...

  7. PMP - 项目管理思维导图

  8. java中的负数的问题

    在计算机中是使用二制数中的最高位表示来正负. 二进制的储存中都是用的补码,正数的原码.反码和补码相同,负数的原码是最高位为1,反码最高位不变,其余各位取反,补码为其反码+1(重要!!) 首先得知道最高 ...

  9. json对象的解析

    json对象数据: { "status": "200", "code": "", "msg": &q ...

  10. 保利威视Polyv点播集成

    demo和文档下载地址http://dev.polyv.net/2014/08/sdk/ 1.demo是eclipse的,所以导入android studio有几个要注意的地方 导入方式 在app的b ...