OpenJudge / Poj 1003 Hangover
链接地址:
Poj:http://poj.org/problem?id=1003
OpenJudge:http://bailian.openjudge.cn/practice/1003
题目:
Hangover
Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 94993 Accepted: 46025 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.00Sample Output
3 card(s)
61 card(s)
1 card(s)
273 card(s)Source
思路:
水题
代码:
#include "stdio.h"
//#include "stdlib.h"
int main()
{
float a,sum;
int i;
scanf("%f",&a);
while(a!=)
{
i = ;
sum = ;
while(sum < a)
{
sum += ((float)/i);
i++;
}
printf("%d card(s)\n",i-);
scanf("%f",&a);
}
//system("pause");
return ;
}
OpenJudge / Poj 1003 Hangover的更多相关文章
- POJ.1003 Hangover ( 水 )
POJ.1003 Hangover ( 水 ) 代码总览 #include <cstdio> #include <cstring> #include <algorithm ...
- [POJ 1003] Hangover C++解题
Hangover Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 95164 Accepted: 46128 De ...
- poj 1003:Hangover(水题,数学模拟)
Hangover Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 99450 Accepted: 48213 Descri ...
- [POJ] #1003# Hangover : 浮点数运算
一. 题目 Hangover Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 116593 Accepted: 56886 ...
- 快速切题 poj 1003 hangover 数学观察 难度:0
Hangover Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 103896 Accepted: 50542 Descr ...
- poj 1003 Hangover
#include <iostream> using namespace std; int main() { double len; while(cin >> len & ...
- POJ 1003:Hangover
Hangover Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 109231 Accepted: 53249 Descr ...
- poj 1003 (nyoj 156) Hangover
点击打开链接 题目大意 就是有很多卡片可以沿着桌边向外放,每次可以伸出1/2,1/3,1/4问最少多少卡片才能让一张完成的卡片悬空,题目输入卡片的宽度,输出卡片个数 #include<stdio ...
- Hangover POJ - 1003
How far can you make a stack of cards overhang a table? If you have one card, you can create a maxim ...
随机推荐
- ECSHOP在线手册布局参考图--商品详情页 goods.dwt
A.购物车 1,设置方法 程序自动读取购物车的商品数量 2,代码相关 cart.lbi 中 {insert_scripts files='transport.js'} <div clas ...
- Volley使用指南第一回(来自developer.android)
最近闲来想看看android网络方面的东西.google在2013年发布了一个叫做Volley的网络请求框架,我看了一下官网,居然在training里面就有教程.首先,英文的东西看着 还是挺不爽的,特 ...
- 取消jQuery validate验证
有时候当我们在编辑页面点保存后加上了validate错误验证后又想用表单提交的方式返回界面没有清除验证就返回不了 加上这句话就清除验证了 注意:remove()是删除了相关标签 我这需求是 ...
- hdu 5461 Largest Point 暴力
Largest Point Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid= ...
- callerloc
callerloc An Android app to show location info of incoming calls or outgoing calls in a floating win ...
- 跟Android初学者分享几点经验
刚学Android开发的人肯定想知道过来人是怎样入门的,有哪些经验,怎样能少走弯路.本文就跟大家分享一位Android开发者的入门经验,写的条理很清晰,真正讲出了自己的学习过程,尽管每个人的学习方法和 ...
- Redis缓存 ava-Jedis操作Redis,基本操作以及 实现对象保存
源代码下载: http://download.csdn.net/detail/jiangtao_st/7623113 1.Maven配置 <dependency> <groupId& ...
- Linux下文件描述符
http://blog.csdn.net/kumu_linux/article/details/7877770 文件描述符是一个简单的整数,用以标明每一个被进程所打开的文件和socket.第一个打开的 ...
- Route Filters
Route Filters The Controller's Middleware, represents a High-Level processing API, executed by the r ...
- 正则表达式 之 C#后台应用
正则表达式在.Net就是用字符串表示,这个字符串格式比较特殊,无论多么特殊,在C#语言看来都是普通的字符串,具体什么含义由Regex类内部进行语法分析. Regex 类 存在于 System.Text ...