FZU Problem 1002 HangOver【】
来源:互联网 发布:淘宝一元秒杀 编辑:程序博客网 时间:2024/05/01 15:50
Accept: 2670 Submit: 11015
Time Limit: 1000 mSec Memory Limit : 32768 KB
Problem 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
Sample Output
#include<iostream>#include<cstdio>#include<math.h>#include<cstring>#include<climits>#include<string>#include<queue>#include<stack>#include<set>#include<map>#include<list>#include<vector>#include<sstream>#include<algorithm>using namespace std;#define rep(i,j,k)for(i=j;i<k;i++)#define per(i,j,k)for(i=j;i>k;i--)#define ms(x,y)memset(x,y,sizeof(x))#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1#define ll long longconst int INF=0x7ffffff;const int M=1e5+10;double i,j,k,m,q;char s[M];int a[M];int b[M];double n,sum;int main(){ while(~scanf("%lf",&n)){ if(n==0)break; int ans=0; sum=0; for(i=1;;i++){ sum+=1.0/(i+1.0); ans++; if(sum>=n)break; } printf("%d card(s)\n",ans); } return 0;}
- FZU Problem 1002 HangOver【】
- fzu 1002 HangOver
- FZU 1002 HangOver
- Problem 1002 HangOver
- FZU 1002 HangOver(简单题目)
- ZOJ problem-1045 HangOver
- ZOJ Problem Set - 1045 HangOver
- ZOJ Problem Set - 1045||HangOver
- FZU Problem 2104 Floor problem
- FZU problem 1985 LCP Problem
- fzu problem 1013 rpgame
- FZU Problem 2110 Star
- FZU Problem 2054 拳王
- FZU 1692 Key problem
- FZU 2104 Floor problem
- FZU 2108 MOD problem
- fzu Problem 2154 YesOrNo
- fzu Problem 2152 文件系统
- 【OpenCV学习笔记】一、OpenCV介绍与安装配置
- 选夫婿2 (sdut oj)
- Redux的全家桶与最佳实践
- linux下如何读取使用iso 镜像文件的方法
- 关于Myeclipse8.5在程序运行中查看变量值的问题
- FZU Problem 1002 HangOver【】
- 廖大JS教程的笔记
- 恶搞小程序
- 使用nodepad++创建html模板
- hibernate自定义主键生成器详解
- 分享一个react + redux 完整的项目,同时写一下个人感悟
- CentOS7安装MariaDB成功的实践
- 一道被"坑"到的前端Javascript面试题
- js基础8-应用案例