欧美三区_成人在线免费观看视频_欧美极品少妇xxxxⅹ免费视频_a级毛片免费播放_鲁一鲁中文字幕久久_亚洲一级特黄

POJ ACM習(xí)題【No.1003】

系統(tǒng) 2127 0
Hangover
Time Limit: 1000MS Memory Limit: 10000K
Total Submissions: 42388 Accepted: 19686

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.


POJ ACM習(xí)題【No.1003】

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.00

  

Sample Output

    3 card(s)
61 card(s)
1 card(s)
273 card(s)
  

?

解題思路:最小的張數(shù)就是大于總長度的第一個(gè)數(shù)字,注意使用浮點(diǎn)數(shù)。

?

?

    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;
	}

}

  
?

POJ ACM習(xí)題【No.1003】


更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯(lián)系: 360901061

您的支持是博主寫作最大的動(dòng)力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點(diǎn)擊下面給點(diǎn)支持吧,站長非常感激您!手機(jī)微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點(diǎn)擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動(dòng)力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會(huì)非常 感謝您的哦!!!

發(fā)表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 亚洲国产精品99久久久久久久久 | 国产普通话自拍 | 日日干夜夜干 | 久久久精品 | 亚洲综合在线播放 | 婷婷色综合网 | 久操色 | 国产成人综合95精品视频免费 | 亚欧视频在线观看 | 福利免费在线观看 | www国产成人免费观看视频,深夜成人网 | 国产精品美女久久久久aⅴ国产馆 | 无码色情影片视频在线看免费 | 午夜精品小视频 | 国产精品国产三级国产播12软件 | 亚洲欧美日韩另类精品一区二区三区 | 黄色的视频免费观看 | 久久久久亚洲精品影视 | 国产丝袜av | 精品网站999www | 九九久久精品这里久久网 | 无码无遮挡成人A片 | 鲁一鲁影院| 天天操综合 | 精品女同一区二区三区免费播放 | 日韩中文在线观看 | 自拍偷拍亚洲视频 | 99国产欧美久久精品 | 91欧美精品激情在线观看 | 成年视频免费观看 | 九一传媒在线观看 | 久久亚洲AV成人无码电影A片 | 九一免费国产 | 日本九九视频 | 国产精品高清在线观看 | 欧美 亚洲 一区 | 色哟哟国产成人精品 | 亚洲 精品 综合 精品 自拍 | 欧美黄视频| 日韩综合在线视频 | 亚洲国产成人av好男人在线观看 |