FENCE1 - Build a Fence editorial SPOJ - UCS - Unleash-Coding-Skills

Wednesday, 2 May 2018

FENCE1 - Build a Fence editorial SPOJ - UCS

The link for the problem FENCE1 - Build a Fence :


This problem is an ad-hoc one where we need to find the maximizing area such that endpoints touch the wall and to have maximum area. In this case, we know the semi-circle will make the maximum area.

The given input is the length of arc 'l'

We know that perimeter of a semicircle is:

l = (PIE) * R
 So know we can find R= l/(PIE)

Now the area of the semicircle is ((PIE) *R * R/ 2 ) by substituting R from above equation we get

 Area= (L*L)/(2*(PIE))

Where PIE = 3.1415926

So know we can apply this to our problem FENCE1 - Build a Fence.

The following is CPP solution for the problem FENCE1 - Build a Fence :

#include <bits/stdc++.h>
using namespace std;
int main() {
     int num;
          float res=0;
     return 0;

Happy Coding...............

No comments:

Post a comment