HDOJ 1056 HangOver(水题)
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.
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.
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.00
Sample Output
3 card(s)
61 card(s)
1 card(s)
273 card(s)
英语不好真心看不懂(表示看不懂)。。。说了这么多,其实就是一个大水题。
公式题目给出了,就是求公式的和正好大于输入的n的时候的最小的整数。
import java.util.Scanner;
public class Main{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while(sc.hasNext()){
double n = sc.nextDouble();
if(n==0){
return ;
}
int a=0;
int t = 2;
double sum=0;
do{
sum = sum+(1.0/t*1.0);
a++;
t++;
}while(sum<n);
System.out.println(a+" card(s)");
}
}
}
HDOJ 1056 HangOver(水题)的更多相关文章
- HDOJ 1070 Milk(水题,考英文的)
Problem Description Ignatius drinks milk everyday, now he is in the supermarket and he wants to choo ...
- HDOJ 2317. Nasty Hacks 模拟水题
Nasty Hacks Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Tota ...
- poj 1003:Hangover(水题,数学模拟)
Hangover Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 99450 Accepted: 48213 Descri ...
- 水题 HDOJ 4727 The Number Off of FFF
题目传送门 /* 水题:判断前后的差值是否为1,b[i]记录差值,若没有找到,则是第一个出错 */ #include <cstdio> #include <iostream> ...
- 水题 HDOJ 4716 A Computer Graphics Problem
题目传送门 /* 水题:看见x是十的倍数就简单了 */ #include <cstdio> #include <iostream> #include <algorithm ...
- HDOJ/HDU 1328 IBM Minus One(水题一个,试试手)
Problem Description You may have heard of the book '2001 - A Space Odyssey' by Arthur C. Clarke, or ...
- HDOJ/HDU 1256 画8(绞下思维~水题)
Problem Description 谁画8画的好,画的快,今后就发的快,学业发达,事业发达,祝大家发,发,发. Input 输入的第一行为一个整数N,表示后面有N组数据. 每组数据中有一个字符和一 ...
- HDOJ/HDU 2560 Buildings(嗯~水题)
Problem Description We divide the HZNU Campus into N*M grids. As you can see from the picture below, ...
- HDOJ(HDU) 2090 算菜价(简单水题、)
Problem Description 妈妈每天都要出去买菜,但是回来后,兜里的钱也懒得数一数,到底花了多少钱真是一笔糊涂帐.现在好了,作为好儿子(女儿)的你可以给她用程序算一下了,呵呵. Input ...
随机推荐
- MVC模式实现登录以及增删改查之登录(一)
我在这里用的不是maven项目,用的一般的web项目,所以需要用到的架包需要自己去下载添加,在项目中,一定注意环境的配置,我用的是jre1.7 1 新建项目 2 建立好MVC的管理包,导入对应的架 ...
- TCP/IP协议原理与应用笔记09:数据通信---封装
2016-08-091. 数据通信----封装: 2. 协议数据单元: PDU:对等层数据通信的单元. 比如Source端的应用层 和 Destination端的应用层是对等层(L7),这个时候L7 ...
- Android(java)学习笔记219:开发一个多界面的应用程序之两种意图
1.两种意图: (1)显式意图: 在代码里面用intent设置要开启Activity的字节码.class文件: (2)隐式意图: Android(java)学习笔记218:开发一个多界面的应用程序之人 ...
- Python下载漫画
上午起来提不起劲,于是就用电脑看漫画,但是在线看漫画好烦,就想下下来看.一个一个点太麻烦,于是花了点时间用python写了个demo,把爱漫画的漫画下载下来,这样就可以随时随地看了.这也是我首次尝试用 ...
- C#_事件委托
CarDealer类 事件发布程序 using System; using System.Collections.Generic; using System.Linq; using System.Te ...
- HDU5319
题意:给一个矩形染色,顺笔表示红色,逆笔表示蓝色(既一捺和一丿),交叉表示绿色,然后给你一个图,问你用多少笔能画出这个图来. 思路:对这个图直接模拟即可,如果点i,j坐标为红色,那么判断上一个路径点是 ...
- Android模拟器访问本地的localhost失败及解决方案
在开发手机网站是,使用Android模拟器测试,在手机浏览器中输入localhost访问本地服务器失败! 原因: 在Android系统中localhost就是127.0.0.1 在Windows系统中 ...
- Web中常用字体介绍(转)
1.在Web编码中,CSS默认应用的Web字体是有限的,虽然在新版本的CSS3,我们可以通过新增的@font-face属性来引入特殊的浏览器加载字体. 浏览器中展示网页文字内容时,文字字体都会按照设计 ...
- Android 笔记
一.MTK Android version在文件下build/core/version_defaults.xml下定义. 二.Android 重新编译frameworks/base/core/res资 ...
- js字符串比较
1,大写字母小于小写字母 a='ang',b='Zh' 那么a>b 2,可以使用字符串的toUpperCase()/toLowerCase()方法不区分字母的大小写. a.toUpperCase ...