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

thanks...

#include <stdio.h>
#include <math.h>

#define PI 3.1416

int main()
{
        double a, r, area;

        scanf("%lf%lf", &a, &r);
        a /= 2;

        if (a >= r) {
                printf("%.3f\n", PI * r * r);
                return 0;
        }
        if (r >= sqrt(2) * a) {
                printf("%.3f\n", 4 * a * a);
                return 0;
        }
        printf("%.3f\n", PI * r * r - 4 * (acos(a / r) * r * r - a *
sqrt(r * r - a * a)));
        return 0;
}
Song Chao (ECUST Mutistar) I don't know whether <math.h> is allowed,but you can... [2] // Problem 1084. Goat in the Garden 24 Feb 2002 08:09
> thanks...
>
> #include <stdio.h>
> #include <math.h> ??????

You can use integral to calculate the area Instead of using any
mathematic function.
mon I got the answer [1] // Problem 1084. Goat in the Garden 3 Apr 2002 12:33
I should use ".3lf" instead of ".3f" in the format string
of printf.
silentfish but was that AC??? // Problem 1084. Goat in the Garden 20 Apr 2002 17:43
> I should use ".3lf" instead of ".3f" in the format string
> of printf.
#define PI 3.1416 // no
#define PI 3.1415926535897932 //yes
Better to use standard M_PI

Edited by author 17.05.2014 17:54