HangOver
HangOver
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 7693 Accepted Submission(s): 3129
Problem 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.
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.
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)
Source
题目没什么难度,分明就是某年NOIP的级数求和,不过题目里如果不说,我还真不一定能想到,这个结论得记一下.
#include<stdio.h>
#include<string.h>
int f[];
double s[];
void getprepared()
{
memset(f,,sizeof(f));
memset(s,,sizeof(s));
s[]=0.5;
for (int i=;i<=;i++) s[i]=s[i-]+1.0/(i+);
for (int i=;i<=;i++)
{
double x=i/100.0;
for (int j=;j<=;j++)
if (s[j]>=x)
{
f[i]=j;
break;
}
}
}
int main()
{
getprepared();
double ss;
while (scanf("%lf",&ss)!=EOF)
{
if (ss==) return ;
int x=*ss;
printf("%d card(s)\n",f[x]);
}
return ;
}
HangOver的更多相关文章
- poj 1003:Hangover(水题,数学模拟)
Hangover Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 99450 Accepted: 48213 Descri ...
- Hangover[POJ1003]
Hangover Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 121079 Accepted: 59223 Descr ...
- [POJ1003]Hangover
[POJ1003]Hangover 试题描述 How far can you make a stack of cards overhang a table? If you have one card, ...
- 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 ...
- OpenJudge / Poj 1003 Hangover
链接地址: Poj:http://poj.org/problem?id=1003 OpenJudge:http://bailian.openjudge.cn/practice/1003 题目: Han ...
- POJ1003 – Hangover (基础)
Hangover Description How far can you make a stack of cards overhang a table? If you have one card, ...
- 快速切题 poj 1003 hangover 数学观察 难度:0
Hangover Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 103896 Accepted: 50542 Descr ...
随机推荐
- 关于visio 2007导入独立图库
很多作网络拓扑或服务器系统拓扑时,我们都会找到相关的Visio图库来画,但很多时候我们不知如何才能够直接导入,下面是我自己的导入方式,供大家参考下! 打开07Visio,自动加载设置: 工具--> ...
- [Effective JavaScript 笔记]第24条:使用变量保存arguments对象
迭代器(iterator)是一个可以顺序存取数据集合的对象.其一个典型的API是next方法.该方法获得序列中的下一个值. 迭代器示例 题目:希望编写一个便利的函数,它可以接收任意数量的参数,并为这些 ...
- LSB 简介
前 Linux 的发行版非常繁多,为了促进 Linux 不同发行版间的兼容性,LSB(Linux Standards Base)开发了一系列标准,使各种软件可以很好地在兼容 LSB 标准的系统上运行, ...
- spring中注解的通俗解释
我们在没有用注解写spring配置文件的时候,会在spring配置文件中定义Dao层的bean,这样我们在service层中,写setDao方法,就可以直接通过接口调用Dao层,用了注解写法后,在配置 ...
- 不使用arc功能时的编译参数 –fno-objc-arc
用一些老代码时,里面总有release调用,你需要用上这个标记,不使用arc功能编译代码.我总记不住具体写法,做个记录.
- svn 切换默认用户名
2015年1月19日 15:37:30\ 原文: http://www.2cto.com/os/201307/229325.html linux svn切换用户 1. 临时切换 在所有命令下强 ...
- Linux下配置Tomcat服务器
Linux下配置Tomcat服务器和Windows下其实差不多,可以去官网下载安装包释放或者在线下载,只是当时下载的windows.zip文件,现在下载.tar.gz格式的即可,下面使用命令行的方式安 ...
- 基于Delphi的三层数据库系统的实现方法
基于Delphi的三层数据库系统的实现方法 1 引言 当前的数据库应用系统中,按其结构划分为两类,一类是两层结构的数据库应系统,另一类是多层结构的数据库应用系统. 两层结构的数据库应用系统包括客 ...
- ios xcode Could not load the "MyImage.png" image referenced from a nib in the bundle with identifier "com.mytest.MyProject"
出现找不到xib指定的图片,需要指定图片的完整路径,不能只是图片名 详见:http://vocaro.com/trevor/blog/2012/10/21/xcode-groups-vs-folder ...
- 一、HTML和CSS基础--网页布局--网页简单布局之结构与表现原则
结构.表现和行为分离,不仅是一项技术,更主要的是一种思想,当我们拿到一个网页时,先考虑设计图中的文字内容和内容模块之间的关系,重点放在编写html结构和语义化,然后考虑布局和表现形式.,减少HTML与 ...