... HAVE U TRIED .... AT LEAST 3 TIMES ... OK U CAN SEE THIS ...

Tuesday, December 24, 2013

UVA-10432 :: Polygon Inside A Circle

#include <bits/stdc++.h>
using namespace std;

int main ()
{
    double  r , x ,y ,a ,s ,v ,d  ,pi=acos(-1) ;
    int n ;
    while (scanf ("%lf %d",&r,&n) == 2)
    {
        d=360/n ;
        d=(d*pi)/180.0 ;

        x=r*sqrt(2.0-2.0*cos(d)) ;
        s=0.5*(r+r+x) ;

        v=sqrt(s*(s-r)*(s-r)*(s-x)) ;
        v=v*n ;
        printf ("%.3lf\n",v) ;

    }
    return 0 ;
}