Saturday, 13 February 2016

Light OJ 1056 (Olympic)

#include<bits/stdc++.h>
#define pi acos(-1.0)
using namespace std;
int main()
{
    long long int i,j,k,l,m,n,test;
    double angle,a,b,slice,rad,d,len,wide,rat;
    char ch;
    cin>>test;
    for(k=1;k<=test;k++)
    {
        cin>>a>>ch;
        cin>>b;
        rad=sqrt(((a/2.0)*(a/2.0))+((b/2.0)*(b/2.0)));
        angle=acos((2.0*rad*rad-b*b)/(2.0*rad*rad));
        slice=rad*angle;
        rat=400.0/(2.0*(a)+2.0*slice);
        len=a*rat;
        wide=b*rat;
        printf("Case %lld: %.8f %.8f\n",k,len,wide);
    }
    return 0;
}

No comments:

Post a Comment