My Weblog

SPOJ 4408. Build a Fence

SPOJ 4408. Build a Fence is related to area of circle . When we will fold the fence of length of L then it will circumference of semi circle [ Although i haven’t proved why for maximum , it should be circle ? Intuition again ] .$\pi *r = L$. We have $r = \frac L \pi$. Area of semi circle is $\frac {\pi * r * r} 2 = \frac {L^2} {2 * \pi}$ .

import Data.List
import qualified Data.ByteString.Char8 as BS
import Text.Printf

main = do
when (n /=0 ) \$ do
printf "%.2f\n" ( n*n / 2 / pi )
main


May 31, 2011 - Posted by | Programming | ,