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 my solution is wrong? Help please
Posted by Krabche 30 May 2009 13:01
This is my program
program n1084;
var a, r:integer;
c, l, x, st, cosf, tgf, sinf, f, ss, st1, so, so1:real;
begin
readln(a, r);
if r<=a/2 then
 c:=3.14*r*r
else
 if r>=sqrt(a*a/2) then
  c:=a*a
 else
  begin
   l:=a/2-sqrt(r*r-a*a/4);
   x:=sqrt(2*l*l);
   st:=0.5*l*l;
   cosf:=(2*r*r-x*x)/(2*r*r);
   sinf:=sqrt(1-cosf*cosf);
   tgf:=sqrt((1/(cosf*cosf))-1);
   f:=ArcTan(tgf);
   ss:=f*r*r/2;
   st1:=0.5*r*r*sinf;
   so:=ss-st1;
   so1:=st-so;
   c:=a*a-4*so1;
  end;
write(c:0:3);
end.
When I tested it in home, answer was right. But when I send it, I have error in 2 test, Wrong Answer. Why?
Re: Why my solution is wrong? Help please
Posted by suhanov 30 Apr 2011 10:40
Take the constant Pi with greater precision.