POJ-1003 Hangover-纸牌叠放
来源:互联网 发布:java泛型 pdf 编辑:程序博客网 时间:2024/06/04 17:46
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)
Source
Mid-Central USA 2001
#include <iostream> using namespace std; int main() { int i; double length,sum; while(1) { cin >> length; sum = 0; if(length == 0.00) break; for(i = 1; i < 300; i++) { sum += 1.0/(i+1); if(sum >= length) { cout << i << " card(s)\n"; break; } } } return 0; }
- POJ-1003 Hangover-纸牌叠放
- POJ 1003--Hangover
- (POJ 1003)Hangover
- poj 1003Hangover
- POJ 1003 Hangover
- poj 1003 Hangover
- poj 1003(Hangover)
- 【POJ】1003 Hangover
- POJ-1003:Hangover
- [POJ]1003 Hangover
- POJ 1003 Hangover
- poj 1003 Hangover
- POJ 1003 Hangover
- 【POJ-1003】Hangover
- POJ-1003-Hangover
- poj 1003 Hangover
- POJ 1003 Hangover
- [POJ][1003]Hangover
- C语言枚举的用法
- 【黑马程序员】内存管理概念及原理
- hdu 5353 Average(暴力)
- hdu 5358 First One(想法题)
- poj 1142 Smith Numbers
- POJ-1003 Hangover-纸牌叠放
- C++(9)语句
- #每日一面BAT#第1题:概率与集合元素个数
- HDU 1301 Jungle Roads prim算法 最小生成树
- ondraw() 和dispatchdraw()的区别
- centos中 kvm 网桥的设置
- 一串字符去掉c和d
- OC循环渐进:单例设计模式
- hdu 5355 Cake(回溯)