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

WA #9!! What's the tricky test case here?
Posted by Cyclops 31 Oct 2008 22:15
WA #9!! What's the tricky test case here?
Please help..

#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

int main()
{
    int side, cord;
    double alas, tinggi, bagi, cos_segi, luas1, luas2, maxCord, tembereng, luasAll;
    const double pi=3.1415926535897932384626433832795;

    cin>>side>>cord;

    tinggi = (side/2);
    maxCord = tinggi * sqrt(2.0);

    if(cord >= maxCord)
       luasAll = side*side;
    else if(cord <= tinggi)
       luasAll = pi*cord*cord;
    else
    {
        bagi = tinggi/cord;
        alas = 2*sqrt(cord*cord - tinggi*tinggi);
        cos_segi = acos(bagi);
        luas1 = alas*tinggi/2;
        luas2 = cos_segi/2*cord*cord;
        tembereng = 2*luas2 - luas1;
        luasAll = pi*cord*cord - 4*tembereng;
    }
    cout<<fixed<<showpoint<<setprecision(3);
    cout<<luasAll;
    return 0;
}

Edited by author 01.12.2008 11:01