永发信息网

ACM题目HangOver题意是什么

答案:1  悬赏:50  手机版
解决时间 2021-05-24 09:38
ACM题目HangOver题意是什么
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)
最佳答案

# include
main()
{
int i;
float len,s;
while(1)
{
scanf(%f,&len);
s = 0.0;
if(0==len) break;
for(i = 2; ; i++)
{
s+=1.0/i;
if(s >= len)
break;
}
printf(%d card(s)\n,i-1);
}
return 0;
}


我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
清丰县濮阳中通&圆通&韵达快递地址在哪,我要
如何识女仔?
为甚麽人总是自私自利的呢?
松滋市东鹏瓷砖(荆州松滋店)地址在哪,我要去
2010什么样的女人可靠
我对笔记本一窍不通,想买一个4000元以下的.请
我想找工作,但不知道做什么?朋友们介绍几个
永定区张家界星光舞台歌友会俱乐部地址在哪,
短道运动员的总结能写吗?
季桥镇颜刘村村民委员会地址在什么地方,想过
昆山商厦NIKE,ADIDAS何时打折
湛河区平顶山康泰养生足疗会馆哪位知道具体地
郑州 周口的朋友请进来一下
襄城县许昌丰泽园鸡汤火锅(文昌路店)这个地址
nancy什么dalian with her parents next year
推荐资讯
仙桃市仙桃中国福利彩票怎么去啊,谁知道地址
沈丘县周口高记卤肉(总店)在哪里啊,我有事要
雨湖区湘潭楠竹山派出所地址是什么,有没有知
祁阳县永州君子兰酒店在什么地方啊,我要过去
香坊区哈尔滨老合合快餐哪位知道具体地址啊
和你一起变老的句子,一起白头到老的句子十六
宜城市襄樊中国农业银行(宜城市支行城关分理
小和尚下山的问题
诺基亚X3 短信密码设置的软件
周杰伦的新歌什么时候发表?
布朗夫人请他的好朋友到家里吃饭 Mrs brown a
岳麓区长沙曾红公寓在什么地方啊,我要过去处
正方形一边上任一点到这个正方形两条对角线的
阴历怎么看 ?