ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1084. Goat in the Garden

why WA on test#6 !!!!!!!help
Posted by deepbluesea 9 Jun 2007 13:02
#include<iostream>
#include<fstream>
#include<sstream>
#include<vector>
#include<cmath>
#include<queue>
#include<string>
#include<iomanip>

using namespace std;

int main(){

    //1084
    double glength,r;

    double pi = 3.1415926535897932384626433832795;

    cin>>glength>>r;

    cout<<setiosflags(ios::fixed)<<setiosflags(ios::showpoint)<<setprecision(3);

    if(glength >= r * 2.0){
        cout<<r*r*pi<<endl;
        return 0;
    }
    if(glength * pow(2.0,0.5) <= r){
        cout<<glength*glength<<endl;
        return 0;
    }
    else{
        double d = pow((pow(r,2.0) - pow(glength/2.0,2.0)),0.5);
        double area = glength/2.0 * d/2.0;
        double arc = pi/4.0 - acos(0.5*glength/r);
        cout<< 8.0*(0.5*arc*r*r+area)<<endl;
        return 0;
    }

}