国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

poj1003 Hangover

2019-11-14 20:58:54
字體:
來源:轉載
供稿:網友
poj1003 Hangover

DescriptionHow 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 makencards 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.003.710.045.190.00          

Sample Output

3 card(s)61 card(s)1 card(s)273 card(s)
import java.util.*;   public class Main {       public static void main(String[] args) {           Scanner cin = new Scanner(System.in);           String str;           int maxCardNum = 0;           while(cin.hasNext())           {               str = cin.nextLine();               if(str.equals("0.00"))                   break;               float len = Float.valueOf(str).floatValue();               maxCardNum = getCardNum(len);               System.out.PRintln(maxCardNum + " card(s)");           }         }              private static int getCardNum(float len)       {           float value = 0;           int index = 2;             while (value < len)           {               value += 1.0/index;               index++;           }                          return index-2;       }     }  


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 额尔古纳市| 桦南县| 谢通门县| 嘉禾县| 泰和县| 莱西市| 奉贤区| 通河县| 襄汾县| 刚察县| 仙游县| 平湖市| 晋城| 黄冈市| 达日县| 盘锦市| 东平县| 白山市| 三江| 凌海市| 叶城县| 依安县| 嘉鱼县| 邻水| 怀仁县| 长丰县| 宜兴市| 岢岚县| 龙陵县| 红河县| 陇川县| 罗定市| 吴堡县| 仁布县| 平凉市| 库车县| 原阳县| 惠安县| 阜阳市| 上饶县| 湖南省|