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

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) 题意:求sum(1/n)=给定数的n
思路:因为n只有可能300种,预处理比较即可,精度0.01,不需要设置eps
#include <iostream>
double tc;
double sum[300];
using namespace std;
int main(){
ios::sync_with_stdio(false);
double s=0;
for(int i=0;i<300;i++){
s+=1.00/(i+2);
sum[i]=s;
}
while(cin>>tc&&tc){
int i=0;
for(int i=0;i<300;i++){
if(sum[i]>=tc){
cout<<i+1<<" card(s)"<<endl;
break;
}
}
if(i==300)cout<<"ERROR"<<endl;
}
return 0;
}

  

快速切题 poj 1003 hangover 数学观察 难度:0的更多相关文章

  1. 快速切题CF 158B taxi 构造 && 82A double cola 数学观察 难度:0

    实在太冷了今天 taxi :错误原因1 忽略了 1 1 1 1 和 1 2 1 这种情况,直接认为最多两组一车了 2 语句顺序错 double cola: 忘了减去n的序号1,即n-- B. Taxi ...

  2. POJ.1003 Hangover ( 水 )

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

  3. 快速切题 poj 2996 Help Me with the Game 棋盘 模拟 暴力 难度:0

    Help Me with the Game Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 3510   Accepted:  ...

  4. 快速切题 poj 2993 Emag eht htiw Em Pleh 模拟 难度:0

    Emag eht htiw Em Pleh Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 2806   Accepted:  ...

  5. 快速切题 poj 1002 487-3279 按规则处理 模拟 难度:0

    487-3279 Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 247781   Accepted: 44015 Descr ...

  6. 快速切题 poj 3026 Borg Maze 最小生成树+bfs prim算法 难度:0

    Borg Maze Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 8905   Accepted: 2969 Descrip ...

  7. 快速切题 poj 2485 Highways prim算法+堆 不完全优化 难度:0

    Highways Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 23033   Accepted: 10612 Descri ...

  8. OpenJudge / Poj 1003 Hangover

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

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

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

随机推荐

  1. 学习Android开发看那些书好?

    学习一样新事物或许有多种方式,报培训班,看视频,向高手请教等等,但一本好书往往可以让你少走很多弯路,事半功倍. 下面推荐几本个人觉得搞Android开发值得一读的书籍. Head First Java ...

  2. WLAN QOS

    1. 理解WLAN QOS 1.1       WLAN QOS简介 802.11的WLAN网络为用户提供了公平竞争无线资源的无线接入服务,但不同的应用需求对于网络的要求是不同的,而原始802.11网 ...

  3. python在CentOS 7中的安装

    CentOS 7 中默认安装了python2.7.5,可能部分开发人员需要使用python3系列的产品,因为版本不“向下”兼容,诸如print函数,因此需要对于不同的项目进行python版本之间的切换 ...

  4. 20145312 实验五 《Java网络编程》

    20145312 实验五<Java网络编程> 一. 实验内容及要求 实验内容: 运行下载的TCP代码,结对进行,一人服务器,一人客户端: 利用加解密代码包,编译运行代码,一人加密,一人解密 ...

  5. 20145322《Java程序设计》第3次实验报告

    实验内容,, 组队使用 git 上传代码并且互相下载对方代码修改之后再上传. 实现代码的重载 一. 使用git 上传代码 过程如图: 仨人成功上传后的代码图如下: 使用git 相互更改代码 执行git ...

  6. 20145324 《Java程序设计》第8周学习总结

    20145324 <Java程序设计>第8周学习总结 教材学习内容总结 第十四章 1.NIO使用频道来衔接数据节点,可以设定缓冲区容量,在缓冲区中对感兴趣的数据区块进行标记,提供clear ...

  7. 【读书笔记】《深入浅出nodejs》第五章 内存控制

    海量请求+长时间运行 -> 内存控制 -> 一切资源高效循环利用 1. V8的垃圾回收机制与内存限制 在Node中通过JavaScript使用内存时,只能使用部分内存(64位系统下约1.4 ...

  8. 【Semantic Segmentation】U-Net: Convolutional Networks for Biomedical Image Segmentation 论文解析(转)

    目录 0. 前言 1. 第一篇 2. 第二篇 3. 第三篇keras实现 4. 一篇关于U-Net的改进 0. 前言   今天读了U-Net觉得很不错,同时网上很多很好很详细的讲解,因此就不再自己写一 ...

  9. Openssl VS编译方法

    工具: 1. 编译环境win10+vs2015专业版 2. ActivePerl工具,官网下载链接:http://www.activestate.com/activeperl/downloads 3. ...

  10. codeforces570D Tree Requests

    题目链接:codeforces570D 正解:$dsu$ $on$ $tree$ 解题报告: 考虑这又是一类子树内的不带修改统计问题,直接上$dsu$ $on$ $tree$好咯. 直接按上一道题的做 ...