[1003]Hangover(水题)
来源:互联网 发布:好的视频剪辑软件 编辑:程序博客网 时间:2024/06/06 19:55
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.003.710.045.190.00
Sample Output
3 card(s)61 card(s)1 card(s)273 card(s)
#include <iostream>using namespace std;int main(){ double a,b; int num;//记录卡片的个数 while(cin>>a,a) { num=1; b=1.0/2;//b记录当前卡片的长度 while(b<a) { num++; b+=1.0/(1+num); } cout<<num<<" card(s)"<<endl; } return 0;}
- Hangover - POJ 1003 水题
- [1003]Hangover(水题)
- poj 1003 hangover 水题
- POJ 1003 Hangover 水题
- poj 1003 Hangover(数学题 水题)
- POJ 1003 Hangover (水题)
- 1003Hangover
- 1003 Hangover
- 1003Hangover
- 1003 Hangover
- 1003 Hangover
- 1003 Hangover
- 1003:Hangover
- 1003 Hangover
- 1003 Hangover
- 1003 Hangover
- Hangover(水题)
- Pku oj 1003 Hangover(水题)
- jquery中的常用事件bind、hover、toggle等示例介绍
- 黑马程序员---description方法(NSLog输出)
- Centos6.4 +Hadoop 1.2.1集群配置
- jsp中kindeditor富文本编辑器的使用
- Android基础之——startActivityForResult启动界面并返回数据,上传头像
- [1003]Hangover(水题)
- android开发
- activeMQ数据消费了,但是在中间站却没有删除数据的原因
- servlet(4) - servletAPI - 小易Java笔记
- ASP.net表格Gridview行编辑
- UVA10047独轮车
- 海南哪家医院治过敏性鼻炎最省钱?
- Android中shape的使用
- g_idle_add