POJ 1003 Hangover
来源:互联网 发布:spss因子载荷矩阵 编辑:程序博客网 时间:2024/06/09 22:14
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
#include <iostream>using namespace std;int main(){double a;while(cin>>a){if(a<0.0001)return 0;double num=0.0;for(int i=2;;i++){num+=1.0/i;if(num-a>0.0000001){cout<<i-1<<" card(s)"<<endl;break;}}}return 0;}
- 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
- poj 1003 Hangover
- 黑马程序员—JAVA高新技术_反射
- 1036. Boys vs Girls (25)
- Java GC
- UVA 12652 Lines of Containers
- codeforces round260 div1B&div2D A Lot of Games字典树上博弈
- POJ 1003 Hangover
- 2.1.8 3Sum
- POJ 1004 Financial Management
- http://www.56.com/p66/v_MTMwODk0ODYz.html
- 1037. Magic Coupon (25)
- 数据科学学习笔记(use R)(2)
- 内存布局
- codeforces round260 div1C&div2E Civilization 并查集+树的直径
- haroopad for linux