Hangover[POJ1003]
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
Output
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]的更多相关文章
- [POJ1003]Hangover
[POJ1003]Hangover 试题描述 How far can you make a stack of cards overhang a table? If you have one card, ...
- POJ1003 – Hangover (基础)
Hangover Description How far can you make a stack of cards overhang a table? If you have one card, ...
- 【POJ1003】Hangover(二分搜索)
直接用库函数二分即可. #include <iostream> #include <cstring> #include <cstdlib> #include < ...
- POJ-1003&1004
这两题比较简单,就不做分析了,描述下题目,就上代码吧. [题目描述] 1003,其实就是求这个方程的最小n:1/2 + 1/3 + 1/4 + ... + 1/(n + 1) >= c: 100 ...
- poj 1003:Hangover(水题,数学模拟)
Hangover Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 99450 Accepted: 48213 Descri ...
- HangOver
HangOver Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Su ...
- Hangover 分类: POJ 2015-06-11 10:34 12人阅读 评论(0) 收藏
Hangover Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 108765 Accepted: 53009 Descr ...
- HDU1056 HangOver
HangOver Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Descript ...
- [POJ] #1003# Hangover : 浮点数运算
一. 题目 Hangover Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 116593 Accepted: 56886 ...
随机推荐
- Cocoapods的安装报错 - Error installing pods:activesupport requires Ruby version >=2.2.2
1.打开终端 2 移除现有 Ruby 默认源 输入以下指令 $gem sources --remove https://rubygems.org/ 3.使用新的源 输入以下指令 $gem source ...
- php页面判断是 iphone还是andriod的浏览器&通过 URL types在浏览器打开app(转)
http://blog.csdn.net/totogo2010/article/details/8925483 解决一个二维码不同手机扫描下载时跳转的问题 判断后跳转对应的app下载 <?php ...
- 2014百度之星资格赛 1001:Energy Conversion(水题,逻辑题)
Energy Conversion Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others ...
- elementar OS体验
关于其说明请参考https://linuxtoy.org/archives/elementary-os-luna.html
- [LeetCode] Isomorphic Strings
Isomorphic Strings Total Accepted: 30898 Total Submissions: 120944 Difficulty: Easy Given two string ...
- Cube Processing Options
在 Microsoft SQL Server Analysis Services 中处理对象时,您可以选择处理选项以控制每个对象的处理类型. 处理类型因对象而异,并基于自上次处理对象后对象所发生的更 ...
- 使用html5的离线缓存技术
突然想用html5的离线缓存,但是一直没有成功,在各种群里问发现很多人都没什么经验,最终终于在各种论坛找到解决方案了.下面就简单记录一下相关情况. 一.离线缓存的优点 我们都知道离线缓存主要是用来减少 ...
- hdu 4412 2012杭州赛区网络赛 期望
虽然dp方程很好写,就是这个期望不知道怎么求,昨晚的BC也是 题目问题抽象之后为:在一个x坐标轴上有N个点,每个点上有一个概率值,可以修M个工作站, 求怎样安排这M个工作站的位置,使得这N个点都走到工 ...
- 比较两个文件文件可以使用MD5比较工具
举例来说,当我们对一个设备进行升级. 固件程序是一个文件,而我们发送的数据可以组成一个文档, 实质是把这两个文件拖入到下图中的工具中,查看一下MD5值.SHA1值.CRC32的值,如果值都一样说明这两 ...
- DotNet 资源大全中文版,内容包括:编译器、压缩、应用框架、应用模板、加密、数据库、反编译、IDE、日志、风格指南等
DotNet 资源大全中文版 我想很多程序员应该记得 GitHub 上有一个 Awesome - XXX 系列的资源整理.awesome-dotnet 是由 quozd 发起和维护.内容包括:编译器. ...