Tuesday, May 3, 2011

10451 - Ancient Village Sports


#include<iostream>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#define PI 2*acos(0.0)
using namespace std;
int main()
{
    unsigned long int n,k=0;
    long double A,SA,OA,ang,R,r,side;
    freopen("in.txt","r",stdin);
    while(cin>>n&&n>=3)
    {
        cin>>A;
        ang=2*PI/n;
        R=sqrt(2*A/(n*sin(ang)));
        side=2*R*sin(ang/2.0);
        r=R*R*sin(ang)/side;
        SA=PI*R*R-A;
        OA=A-PI*r*r;
        printf("Case %ld: %0.5Lf %0.5Lf\n",++k,SA,OA);
    }
    exit(0);
}

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.