快速切题 poj 1003 hangover 数学观察 难度:0
| Time Limit: 1000MS | Memory Limit: 10000K | |
| Total Submissions: 103896 | Accepted: 50542 |
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) 题意:求sum(1/n)=给定数的n
思路:因为n只有可能300种,预处理比较即可,精度0.01,不需要设置eps
#include <iostream>
double tc;
double sum[300];
using namespace std;
int main(){
ios::sync_with_stdio(false);
double s=0;
for(int i=0;i<300;i++){
s+=1.00/(i+2);
sum[i]=s;
}
while(cin>>tc&&tc){
int i=0;
for(int i=0;i<300;i++){
if(sum[i]>=tc){
cout<<i+1<<" card(s)"<<endl;
break;
}
}
if(i==300)cout<<"ERROR"<<endl;
}
return 0;
}
快速切题 poj 1003 hangover 数学观察 难度:0的更多相关文章
- 快速切题CF 158B taxi 构造 && 82A double cola 数学观察 难度:0
实在太冷了今天 taxi :错误原因1 忽略了 1 1 1 1 和 1 2 1 这种情况,直接认为最多两组一车了 2 语句顺序错 double cola: 忘了减去n的序号1,即n-- B. Taxi ...
- POJ.1003 Hangover ( 水 )
POJ.1003 Hangover ( 水 ) 代码总览 #include <cstdio> #include <cstring> #include <algorithm ...
- 快速切题 poj 2996 Help Me with the Game 棋盘 模拟 暴力 难度:0
Help Me with the Game Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 3510 Accepted: ...
- 快速切题 poj 2993 Emag eht htiw Em Pleh 模拟 难度:0
Emag eht htiw Em Pleh Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 2806 Accepted: ...
- 快速切题 poj 1002 487-3279 按规则处理 模拟 难度:0
487-3279 Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 247781 Accepted: 44015 Descr ...
- 快速切题 poj 3026 Borg Maze 最小生成树+bfs prim算法 难度:0
Borg Maze Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 8905 Accepted: 2969 Descrip ...
- 快速切题 poj 2485 Highways prim算法+堆 不完全优化 难度:0
Highways Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 23033 Accepted: 10612 Descri ...
- 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 ...
随机推荐
- googleBigTable
Bigtable是一个分布式的结构化数据存储系统,它被设计用来处理海量数据:通常是分布在数千台普通服务器上的PB级的数据.Google的很多项目使用Bigtable存储数据,包括Web索引.Googl ...
- Foundations of RESTful Architecture
Introduction The Representational State Transfer (REST) architectural style is not a technology you ...
- Wex5各组件介绍
1.http://doc.wex5.com/comp-base/ 2.select 组件 http://doc.wex5.com/comps-select/ 3.页面交互以及传递参数 http:// ...
- PHP之PDO_MYSQL扩展安装步骤
转载地址:http://www.cnblogs.com/qq78292959/p/4084868.html 看到CakePHP文档要求安装pdo_mysql扩展,于是就尝试安装了一下. 这里我的系统是 ...
- eclipse web项目的发布路径
java Build path是编译路径设置,主要用来设置源代码的编译路径默认是default output folder Web Deployment Assembly是eclipse中的发布路径设 ...
- strcpy、sprintf、memcpy的区别
char*strcpy(char *dest, const char *src); 其对字符串进行操作,完成从源字符串到目的字符串的拷贝,当源字符串的大小大于目的字符串的最大存储空间后,执行该操作会出 ...
- 1_jenkins环境搭建
前言 为什么要使用jenkins 可以实现批量部署.管理 支持常见的版本控制工具,git, svn等 发展成熟,使用范围广,容易找到解决方案 插件丰富,可以满足自己的需求 什么是jenkins 简单的 ...
- jackson序列化字段字母大小写及字段名重复
一:Jackson默认的属性发现规则将会查找到如下所述的属性: 1.所有被public修饰的字段(成员变量): 2.所有被public修饰的getter(即形如“getXxx()”的方法): 3.所有 ...
- SQLite-C#-帮助类
public static class SQLiteHelper { private static string connectionString = string.Empty; #region vo ...
- 8.scala:特质
版权申明:转载请注明出处.文章来源:http://bigdataer.net/?p=317 总体来说,scala中的特质类似于Java中的接口,但是有别于接口的是特质中既可以有实现方法也可以有抽象方法 ...