poj 1003:Hangover(水题,数学模拟)
Time Limit: 1000MS | Memory Limit: 10000K | |
Total Submissions: 99450 | Accepted: 48213 |
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.00
3.71
0.04
5.19
0.00
Sample Output
3 card(s)
61 card(s)
1 card(s)
273 card(s)
Source
#include <iostream> using namespace std; int main()
{
double c,sum;
int n,card;
while(cin>>c){
if(int(c*)==) break;
sum = ;
n=;
while(sum<=c){ //循环模拟。直到超过
sum+=1.0/n;
n++;
}
cout<<n-<<" card(s)"<<endl;
}
return ;
}
Freecode : www.cnblogs.com/yym2013
poj 1003:Hangover(水题,数学模拟)的更多相关文章
- POJ.1003 Hangover ( 水 )
POJ.1003 Hangover ( 水 ) 代码总览 #include <cstdio> #include <cstring> #include <algorithm ...
- 【转】POJ百道水题列表
以下是poj百道水题,新手可以考虑从这里刷起 搜索1002 Fire Net1004 Anagrams by Stack1005 Jugs1008 Gnome Tetravex1091 Knight ...
- OpenJudge / Poj 1003 Hangover
链接地址: Poj:http://poj.org/problem?id=1003 OpenJudge:http://bailian.openjudge.cn/practice/1003 题目: Han ...
- [POJ 1003] Hangover C++解题
Hangover Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 95164 Accepted: 46128 De ...
- poj 3264 RMQ 水题
题意:找到一段数字里最大值和最小值的差 水题 #include<cstdio> #include<iostream> #include<algorithm> #in ...
- Poj 1552 Doubles(水题)
一.Description As part of an arithmetic competency program, your students will be given randomly gene ...
- [POJ] #1003# Hangover : 浮点数运算
一. 题目 Hangover Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 116593 Accepted: 56886 ...
- 最小费用最大流模板 poj 2159 模板水题
Going Home Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 15944 Accepted: 8167 Descr ...
- POJ 1837 Balance 水题, DP 难度:0
题目 http://poj.org/problem?id=1837 题意 单组数据,有一根杠杆,有R个钩子,其位置hi为整数且属于[-15,15],有C个重物,其质量wi为整数且属于[1,25],重物 ...
随机推荐
- 1.Express入门
Express提供了轻量级框架,把Node.js的http模块功能封装在接口中. 也扩展了http模块功能,处理服务器路由,响应,cookie和HTTP请求的状态. 实现Express充当服务器,设计 ...
- Python tab键自动补齐
1.进入root家目录 建立.tab文件 .tab文件内容如下: ############################################## import sys import r ...
- 7.3---直线是否相交(CC150)
注意:就算斜率相等,但是,如果截距也相等,那么是属于相交,所以要特殊判断. public class CrossLine { public boolean checkCrossLine(double ...
- Fibonacci 1
Fibonacci 1 题面 \[F_0=0,F_1=1,F_n=F_{n-1}+F_{n-2}\] 给定\(n\),求 \[S(n)=\sum_{i=1}^{n}F_nF_{n-1}\] 数据格式 ...
- 转:TopN推荐系统——推荐的实现与推荐效果的评价指标
转自:用户推荐系统_python 代码-豆瓣书籍:项亮的<推荐系统实践> import random import math class UserBasedCF: def __init__ ...
- 深入浅出Java回调机制
本文转载自http://hellosure.iteye.com/blog/1130176 在网上看到了一个比喻,觉得很形象,这里借用一下: 你有一个复杂的问题解决不了,打电话给你的同学,你的同学说可以 ...
- 【leetcode】Path Sum II
Path Sum II Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals ...
- 如何使用参数 appActivity+appPackage 和 app
本文针对RobotFrameWork中AppiumLibrary测试库. 首先,Open Application 这个方法不能向手机中安装应用,需要提前在手机中安装好,如使用 adb install ...
- [猜数字]把两个数和告诉A,积告诉B,求这两个数是什么
1-20的两个数把和告诉A,积告诉B,A说不知道是多少,B也说不知道,这时A说我知道了,B接着说我也知道了,问这两个数是多少? 分析: 设和为S,积为M. 首先,A:我不知道. 说明:S可以分解成多个 ...
- PHP生命周期
2015-08-19 15:05:30 周三 一篇很好的文章 PHP内核探索 总结一下 1. 模块初始化 MINIT 各个PHP模块/扩展初始化内部变量, 告诉PHP调用自己的函数时, 函数体在哪里( ...