poj-1003-Hangover
2016-04-14 20:33
459 查看
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.00
Sample Output
3 card(s)
61 card(s)
1 card(s)
273 card(s)
Source
卡片一张盖一张,第1张最多可以延伸1/2的长度,第二张最多延伸1/3的长度,依次类推。给你一个长度,问你最少需要几张卡片才能达到?
水题啊
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.00
Sample Output
3 card(s)
61 card(s)
1 card(s)
273 card(s)
Source
卡片一张盖一张,第1张最多可以延伸1/2的长度,第二张最多延伸1/3的长度,依次类推。给你一个长度,问你最少需要几张卡片才能达到?
水题啊
卡片一张盖一张,第1张最多可以延伸1/2的长度,第二张最多延伸1/3的长度,依次类推。给你一个长度,问你最少需要几张卡片才能达到?
相关文章推荐
- django在Model中修改表名
- Google推出新措施打击广告欺诈点击
- 针对X5新内核Blink以及google chrome主要字体主动放大问题
- Django模板的自动转义
- 一个简单的例子阐述Go的对象复用思想
- Google使用技巧
- LeetCode Algorithms #119 <Pascal's Triangle II>
- 用goto语句写的带父节点的中序遍历
- Django开发环境搭建
- 用Golang写一个搜索引擎
- 基于go语言的心跳响应
- django xadmin多个model的数据渲染在统一个template中
- Django提示django-admin.py: command not found
- 在ubuntu上安装Django的简单方法
- tango with django ch6 Model
- Mongo启动说明
- 百度权力调整:以Google为师,向华尔街示好
- Django
- django 模型 时间戳管理
- VIEWGOOD(远古)图书馆的资源融合与共享应用解决方案