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 #7 Why?
Posted by wolfpro 31 Aug 2013 16:53
#include <iostream>
#include <cmath>
#include <stdio.h>
int main()
{
    using namespace std;
    int nRadius, nLenght;
    double dAnswer, dPi = 3.141592654;
    cin >> nLenght >> nRadius;
    if (nRadius * nRadius >= nLenght * nLenght / 2) {
        dAnswer = nLenght * nLenght;
    } else if (nRadius <= nLenght / 2) {
        dAnswer = nRadius * nRadius * dPi;

    } else {
        double dX = sqrt(nRadius * nRadius - nLenght * nLenght / 4);
        double dSg = dPi * nRadius * nRadius / 360 * (360 - 8 * atan2(dX, nLenght / 2) *  57.296);
        dAnswer = dSg + 4 * nLenght / 2 * dX;
    }
    printf("%0.3f", dAnswer);

    return 0;
}

Edited by author 31.08.2013 17:00

Edited by author 31.08.2013 17:00
Re: WA #7 Why?
Posted by oybek 17 May 2014 17:44
Firstly calculate all in radians, don't even think about degrees, because all
of cmath functions works in radians.
And you should change all integers to double.
Example: change 8 to 8.0 and so on.
Use standart pi constant M_PI

Check all functions.

Edited by author 17.05.2014 17:45