一道看似简单的ACM题检验你的基本功
2008-05-27 12:53
246 查看
This problem do not have any algo. thinking,and the unique facet concerning some math has been revealed in the description.But it exams whether you have a solid foundation in cpp programming.
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
Mid-Central USA 2001
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
Mid-Central USA 2001
相关文章推荐
- 一道简单的acm题目
- 一道看似简单的sql面试题(count,group by,distinct)
- 一道简单的ACM题目讨论
- 一道简单的ACM题目学到的东西
- 一道看似简单的易错数分考研题
- 北方大学ACM多校训练第十四周-又是一道简单题 (树链剖分维护点权)
- 一道简单的acm题的三种解决方案(数组、单向链表、容器vector)与代码优化
- 一道看似简单的面试算法题所隐藏的潜在意图
- (C#)一道看似简单却很难答得完全正确的关于多态的问题
- 一道看似简单的sql需求却难倒各路高手 - 你也来挑战下吗?
- 一道看似简单的面试题
- 一道看似简单的sql需求却难倒各路高手 - 你也来挑战下吗
- 一道看似复杂但是简单的c#面试题
- 一道关于finally的看似非常简单但很多人都做错的Java面试题
- ACM-一道简单的排序题(HDOJ 1031)Design T-Shirt
- 一道看似简单的sql需求却难倒各路高手 - 你也来挑战下吗?
- 【求助】杭电ACM 1001 一道简单问题,老是PE
- 黑马程序员:一道看似简单的题(删除List中的元素)
- 一道简单的acm题目
- 图灵杯-第四届“图灵杯”NEUQ-ACM 程序设计竞赛-F-一道简单的递推题