FENCE1 - 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
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
For each test case, output one line containing the largest area. Your answer should be rounded to 2 digits after the decimal point.
Example
Input: 1 0 Output: 0.16
hide comments
vermast:
2022-05-29 15:17:39
You have to output immediately after every input line. |
|
darkdeveloper:
2021-08-01 18:35:04
Use pi = 3.1415926536
|
|
loser_404:
2021-06-07 16:41:51
for clear concept:
|
|
yasser1110:
2021-05-23 18:22:08
Make sure you use "fixed", if you use cout (like:- cout<<fixed<<setprecision(2)<<ans<<endl;), in cpp otherwise you print results in the exponential format (like 1.6e+03, for 100). Or just use printf. |
|
rudra_hari007:
2020-09-27 14:54:18
What concept is needed for it?
|
|
shaon_debnath:
2020-09-16 20:03:49
Use M_PI present in <math.h> and printf("%.2f") for C++ |
|
avi_kumar15:
2020-05-23 23:43:58
cout<<fixed<<setprecision(2)<<ans<<endl; |
|
elucidase:
2020-05-23 08:02:58
Since at the optimum we should observe symmetry (otherwise strictly worse), we can reflect the fence across the wall. The problem is then equivalent to finding the maximum area of the closed shape given its parameter. |
|
sheersha:
2020-04-21 19:27:47
Use pi = 3.1415926536 |
|
devmayukh:
2019-11-24 10:44:49
Why are you defining Pi yourself? There is M_PI in <math.h> in C/C++, and Math.PI in Java. |
Added by: | Fudan University Problem Setters |
Date: | 2009-05-23 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: C99 ERL JS-RHINO NODEJS PERL6 VB.NET |
Resource: | Fudan University Local Contest #1, practise session |