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. oldboy s21day06

    #!/usr/bin/env python# -*- coding:utf-8 -*- # 1.列举你了解的字典中的功能(字典独有).'''dic.keys() 获取所有keydic.values() ...

  2. ES6 Class语法学习

    前言 大多数面向对象的编程语言都支持类和类继承的特性,而JS却不支持这些特性,只能通过其他方法定义并关联多个相似的对象,这种状态一直延续到了ES5.由于类似的库层出不穷,最终还是在ECMAScript ...

  3. 使用SO_REVTIMEO套接字选项为recvfrom设置超时

    void dg_cli(FILE *fp, int sockfd, const SA *pservaddr, socklen_t servlen) { int n; ]; struct timeval ...

  4. CSRF篇-本着就了解安全本质的想法,尽可能的用通俗易懂的语言去解释安全漏洞问题

    0x01 Brief Description csrf 跨站伪造请求,请求伪造的一种,是由客户端即用户浏览器发起的一种伪造攻击.攻击的本质是请求可以被预测的到. 在了解csrf攻击之前,需要了解浏览器 ...

  5. 个人经验~ 利用5.7的sys库更好的排查问题

    一 简介:今天我们讲讲如何利用5.7的sys新库进行问题的排查二 描述   1 Sys库所有的数据源来自:performance_schema和information_schema.目标是把perfo ...

  6. Django之Cookie和Session

    http://www.cnblogs.com/liwenzhou/p/8343243.html 一.Cookie Cookie是什么? 就是保存在客户端浏览器上的键值对. Cookie为什么存在? 因 ...

  7. python图片转为base64

    # -*- coding: utf-8 -*- import base64 with open("/home/chaowei/1.png","rb") as f ...

  8. 题解 P4692 【[Ynoi2016]谁的梦】

    Ynoi 中少见的不卡常题呢....虽说有 50 个数据点... 果然还是道好题 noteskey 总之就是补集转化的思想,算出每种颜色选点的总方案减去不可行方案(就是不包含 该种颜色的点的区间选取方 ...

  9. SQL中笛卡尔积-cross join的用法

    在数学中,笛卡尔乘积是指两个集合X和Y的笛卡尓积(Cartesian product),又称直积,表示为X × Y,第一个对象是X的成员而第二个对象是Y的所有可能有序对的其中一个成员 假设集合A={a ...

  10. 清北-Day5-R2-divide

    题目描述 问是否可以将一个仅由0~9组成的字符串划分成两个或两个以上部分,使得每一部分的数字总和相等. 输入 输入文件名为 \(divide.in\) 多组数据,第一行一个数\(n\),表示数据组数 ...