4
there is only one rule: get accept for this problem http://acm.ut.ac.ir/sc/problemset/view/1032!
to submit your code, you need to create an account(if you don't want to do so, just post your code here and I'll submit it). so far shortest code is written with C and has 85 character length.
winner will be the shortest C/C++ code submitted before 2012/02/01
note: to check shortest codes submitted you can click on "accepted runs" and then "code length"
as elssar suggested I've copied the question here :
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.
figure http://acm.ut.ac.ir/sc/assets/problem_images/1032_50ac13c53158fd843d1884e8afa962dd.jpg
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)
Would be nice if you copied the question over here. – elssar – 2012-01-16T14:30:58.370
I just saw a guy on 9gag that recently posted an image of this :) – ajax333221 – 2012-01-16T18:53:50.537
Shouldn't there be 5 outputs for 5 inputs? – Thomas Eding – 2012-01-17T04:38:51.300
1I know the problem says C/C++, but that's for the ACM site. Can we post answers in other languages here on CG? – elssar – 2012-01-17T07:24:57.497
@trinithis 0 is used to terminate input, so it's not really an input to program. In any case, the answer for 0 would be trivial - 0 – elssar – 2012-01-17T07:33:26.593
>
The correct solution is actually a harmonic series, but not 1/2 + 1/3 + ... but 1/2 (1 + 1/2 + 1/3 + ...).
– ceased to turn counterclockwis – 2012-01-18T16:38:04.100@leftaroundabout that really doesn't matter right now! it was actually a challenge between me and a bunch of my friends. – Ali1S232 – 2012-01-18T18:23:48.600