// you’re reading...
1 Star2 Stars3 Stars4 Stars5 Stars (3 votes, average: 5.00 out of 5)
Loading...

Classical Problems

SPOJ Problem 4408. Build a Fence (FENCE1) Solution

Description
4408. Build a Fence
There is a wall in your backyard. It is so long that you can’t see its endpoints. You want to build a fence of length L such that the area enclosed between the wall and the fence is maximized. The fence can be of arbitrary shape, but only its two endpoints may touch the wall.

Input Specification
The input consists of several test cases.

For every test case, there is only one integer L (1<=L<=100), indicating the length of the fence. The input ends with L=0.

Output Specification
For each test case, output one line containing the largest area. Your answer should be rounded to 2 digits after the decimal point.

Sample Input
1
7
0

Sample Output
0.16
7.80

Solution (File: 4408.py)

Solution

Runs < 0.001 seconds in Python 2.7.
download arrowUse this link to get the Project Euler Solution Python 2.7 source.

Comments
The test cases are qualified to match the input specification.

Discussion

No comments yet.

Post a comment