UVA Problem 10451 (Ancient Village Sports) Solution

Problem Solving, UVa

 

 

#include <bits/stdc++.h>

#include<iostream>

#include<math.h>

#define pi 2*acos(0.0)



using namespace std;



int main()

{

double n,x,y,a,R,r,A,A1,A2,spect,offic;



int c=0;



while(scanf("%lf %lf",&n,&A)==2 && n>=3)

{



r=sqrt((2*A)/(n*sin(2*pi/n))); //2. Given the radius (circumradius); area(A)=((r^2)nsin(360/n)/2)

R=sqrt( A/(n*tan(pi/n))); //Given the apothem (inradius) area=a^2 ntan(180/n);

                             //printf("Case %d: %.5lf %.5lf\n",i,R,r);

A1=pi*r*r;

A2=pi*R*R;



spect = A1-A;

offic = A-A2;



printf("Case %d: %.5lf %.5lf\n",c+1,spect,offic);



c++;



}   

     return 0 ;

}

 

0 Comments

You may find interest following article