OpenJudge / Poj 1003 Hangover
链接地址:
Poj:http://poj.org/problem?id=1003
OpenJudge:http://bailian.openjudge.cn/practice/1003
题目:
Hangover
Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 94993 Accepted: 46025 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
The
input consists of one or more test cases, followed by a line containing
the number 0.00 that signals the end of the input. Each test case is a
single line containing a positive floating-point number c whose value is
at least 0.01 and at most 5.20; c will contain exactly three digits.Output
For
each test case, output the minimum number of cards necessary to achieve
an overhang of at least c card lengths. Use the exact output format
shown in the examples.Sample Input
1.00
3.71
0.04
5.19
0.00Sample Output
3 card(s)
61 card(s)
1 card(s)
273 card(s)Source
思路:
水题
代码:
#include "stdio.h"
//#include "stdlib.h"
int main()
{
float a,sum;
int i;
scanf("%f",&a);
while(a!=)
{
i = ;
sum = ;
while(sum < a)
{
sum += ((float)/i);
i++;
}
printf("%d card(s)\n",i-);
scanf("%f",&a);
}
//system("pause");
return ;
}
OpenJudge / Poj 1003 Hangover的更多相关文章
- POJ.1003 Hangover ( 水 )
POJ.1003 Hangover ( 水 ) 代码总览 #include <cstdio> #include <cstring> #include <algorithm ...
- [POJ 1003] Hangover C++解题
Hangover Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 95164 Accepted: 46128 De ...
- poj 1003:Hangover(水题,数学模拟)
Hangover Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 99450 Accepted: 48213 Descri ...
- [POJ] #1003# Hangover : 浮点数运算
一. 题目 Hangover Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 116593 Accepted: 56886 ...
- 快速切题 poj 1003 hangover 数学观察 难度:0
Hangover Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 103896 Accepted: 50542 Descr ...
- poj 1003 Hangover
#include <iostream> using namespace std; int main() { double len; while(cin >> len & ...
- POJ 1003:Hangover
Hangover Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 109231 Accepted: 53249 Descr ...
- poj 1003 (nyoj 156) Hangover
点击打开链接 题目大意 就是有很多卡片可以沿着桌边向外放,每次可以伸出1/2,1/3,1/4问最少多少卡片才能让一张完成的卡片悬空,题目输入卡片的宽度,输出卡片个数 #include<stdio ...
- Hangover POJ - 1003
How far can you make a stack of cards overhang a table? If you have one card, you can create a maxim ...
随机推荐
- iOS开发-表视图的使用
// // ViewController.m // Simple Table // // Created by Jierism on 16/7/20. // Copyright © 2016年 Jie ...
- C#-窗体之间传递参数
主窗体: ].Value.ToString(); AddRoomTypeFrm AddRoomTypeFrm = new AddRoomTypeFrm(getroomtypeid); AddRoomT ...
- bmp to jpg
uses Jpeg; function BMPtoJPG(var BMPpic, JPGpic: string): boolean;var Bitmap: TBitmap; JpegImg: TJ ...
- UVA 12627 - Erratic Expansion
一个红球能够分裂为3个红球和一个蓝球. 一个蓝球能够分裂为4个蓝球. 分裂过程下图所看到的: 设当前状态为k1.下一状态为k2. k1的第x行红球个数 * 2 ⇒ k2第2*x行的红球个数. k1的第 ...
- Javascript call与apply记录
[注]:记录自己对javascript中call与apply的见解 总会有些东西会被人拿出来重复的写来写去,为何? 只是因为自己感觉不够了解,所谓好记性不如烂笔头,并且在写的同时也会或多或少的收获到一 ...
- Jordan Lecture Note-5: Kernels
Kernels 我们首先来回顾kernel函数的定义:一个函数$K(x,y)$为kernel函数当且仅当对$\forall g, \int K(x,y)g(x)g(y)dxdy\geq 0$成立.另外 ...
- linux之ubuntu下php环境配置
本文主要说明如何在Ubuntu下配置PHP开发环境LAMP. Ubuntu 搭建 php 环境 所谓LAMP:Linux,Apache,Mysql,PHP 安装 Apache2:(注意可以 ...
- 实例源码--ZXing识别条形码和二维码识别源码
下载源码 技术要点: 1.ZXing库的 使用 2.识别条形码和二 维码 3.自定义视图 4.源码带有非常详 细的中文注释 ...... 详细介绍: 1.ZXing库 ZXing是个很经典的条码/ ...
- Java基础知识强化之网络编程笔记17:Android网络通信之 使用Http的Post方式读取网络数据(基于HTTP通信技术)
使用Http的Post方式与网络交互通信.Post方式需要向网络传输一部分数据,同时具有输入流和输出流. 详见:Android(java)学习笔记210:采用post请求提交数据到服务器(qq登录案例 ...
- PHP之ThinkPHP模板标签操作
Action : $User=M("user"); $list=$User->select(); $this->assign("list ...