POJ1003:Hangover
来源:互联网 发布:java 干10年工资多少 编辑:程序博客网 时间:2024/05/01 15:02
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 maken 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 <stdio.h>int main(){ int n; float a,b; while(~scanf("%f",&b),b) { a = 0.0; for(n = 1;a<b;++n) a+=1.0/(float)(n+1); printf("%d card(s)\n",n-1); } return 0;}
- POJ1003 hangover
- POJ1003 Hangover
- POJ1003:Hangover
- POJ1003 Hangover
- POJ1003---Hangover
- poj1003 Hangover
- poj1003--Hangover
- Poj1003 Hangover
- poj1003 Hangover
- POJ1003-hangOver
- POJ1003 Hangover
- Hangover poj1003
- POJ1003 Hangover
- POJ1003:Hangover
- poj1003 Hangover
- poj1003 -- Hangover
- POJ1003 Hangover
- POJ1003-Hangover
- 觉悟
- 1031. Hello World for U (20)
- web中向浏览器中输出随机图片
- ACTIVITY的LAUNCH MODE详解 SINGLETASK正解
- 指针
- POJ1003:Hangover
- 1032. Sharing (25)
- Installing Octave on Cygwin
- 相同VLAN下不同子网之间的通信
- 1033. To Fill or Not to Fill (25)
- sql存储过程
- 1034. Head of a Gang (30)
- 安卓 异步方法总结
- Notifiction