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 ...
随机推荐
- gem install factory_girl
文章是从个人博客转过来的, 可以直接访问 iwangzheng.com https://github.com/thoughtbot/factory_girl https://github.com/t ...
- 【SpringMVC】SpringMVC系列14之SpringMVC国际化
14.SpringMVC国际化 14.1.概述 14.2.用户切换选择语言
- 面向侧面的程序设计AOP-------《一》概述
Aspect-Oriented Programming(面向方面编程,AOP)正好可以解决这一问题.它允许开发者动态地修改静态的OO模型,构造出一个能够不断增长以满足新增需求的系统,就象现实世界中的对 ...
- OAuth
http://oauth.net http://oauth.net/2/ http://tools.ietf.org/html/rfc6749 人人网:http://wiki.dev.renren.c ...
- xml 解析 java 基础复习
document 解析 sax 解析 dom4j 解析(摘自csdn redarmychen) dom4j是一个Java的XML API,类似于jdom,用来读写XML文件的.dom4j是一个非常 ...
- dom 中事件
阻止表单提交: function aa(){ return false; } function bb(event){ event.preventDefault(); } 事件不再派发: <!DO ...
- XP下使用IIS访问asp出现无权查看网页问题的解决办法
这是用户权限问题,因为你用的磁盘是NTFS格式. 解决方法: 一.添加用户(“Everyone”或者“IUSR_你的机器名”,如IUSR_HONG,即“Internet 来宾用户”) 二.修改用户权限 ...
- osg事件处理器osgGA::GUIEventHandler handle
bool handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa) { osgViewer::View ...
- IntelliJ IDEA快捷键和常用设置
一 快捷键的使用 1.文本编辑删除 ctr + y复制 ctr + D2.智能提示提示 ctr + space智能提示 ctr + shift + space完成当前语句 ctr + ...
- ***Linux文件夹文件创建、删除、改名
Linux删除文件夹命令 linux删除目录很简单,很多人还是习惯用rmdir,不过一旦目录非空,就陷入深深的苦恼之中,现在使用rm -rf命令即可.直接rm就可以了,不过要加两个参数-rf 即:rm ...