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

what's wrong with test9?
Posted by Berlin 21 Jun 2011 20:53
this is my programm (WA 9):
#include <iostream>
#include <cmath>
#include <iomanip>
#define PI 3.1415926535897932
using namespace std;

int answer(int n, int k);
int main()
{
    int a,r;
    cin>>a>>r;
    double d=a/2;
    double O=2*acos(d/r);
    double s=2*r*r*(O-sin(O));
    double sk=PI*r*r;
    double sq=a*a;
    if (r<=a/2) cout<<setiosflags(ios::fixed)<<setprecision(3)<<sk<<endl;
    else if (r>=a*(sqrt(2.0)/2)) cout<<setiosflags(ios::fixed)<<setprecision(3)<<sq<<endl;
    else cout<<setiosflags(ios::fixed)<<setprecision(3)<<sk-s<<endl;
}
Re: what's wrong with test9?
Posted by Berlin 5 Jul 2011 12:16
Please help!
Re: what's wrong with test9?
Posted by Jack Guo 1 Oct 2011 13:21
should be "double d = a/2.0;" in line 3 in main function