Thursday, December 26, 2013

SPOJ 4408. Build a Fence

Here is the problem statement
http://www.spoj.com/problems/FENCE1/

It is obvious that we can obtain the biggest area with formaing a half cyrcle.









As shown in the picture, the yellow part is the area we get and the black part is the wall.
The formula for calculating the area of a cyrcle is pi*r*r. Just because its a half cyccle we need to calculate (pi*r*r)/2


   DOWNLOAD THE FULL SOURCE CODE

2 comments:

  1. How can you say that the maximum area will be formed by a semi-circle and not any other shape?

    ReplyDelete
    Replies
    1. Here you can read about it http://mathforum.org/library/drmath/view/53668.html

      Delete