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

I soon started to use C++ and I don't know why comperror???Please....
Posted by Vlado C++ 13 Jan 2002 18:47
#include <stdio.h>
#include <math.h>
void main(){
double r,a,s,angl,cosa;
scanf("%lf %lf",&a,&r);
if (2*r<a) s=M_PI*r*r;
else if (sqrt(2)*r>a) s=a*a;
else{
  cosa=a/(2*r);
  angl=2*acos(cosa);
  angl=M_PI/2-angl;
  s=((a/2)*sqrt(r*r-(a*a)/4))+angl*r*r/2;
  }
printf("%.3lf\n",4*s);
}
I think that the problem is in M_PI........ Maybe their compiler doesn't support this constant, or at least it has a different name
Posted by Algorist 14 Jan 2002 00:45
> #include <stdio.h>
> #include <math.h>
> void main(){
> double r,a,s,angl,cosa;
> scanf("%lf %lf",&a,&r);
> if (2*r<a) s=M_PI*r*r;
> else if (sqrt(2)*r>a) s=a*a;
> else{
>   cosa=a/(2*r);
>   angl=2*acos(cosa);
>   angl=M_PI/2-angl;
>   s=((a/2)*sqrt(r*r-(a*a)/4))+angl*r*r/2;
>   }
> printf("%.3lf\n",4*s);
> }
Re: I soon started to use C++ and I don't know why comperror???Please....
Posted by - GO - 21 Oct 2005 13:39
i think my reply was too late. but for other people.
when using sqrt(2) or something which arguments are not integer, you should use -> sqrt(2.0) instead.
Re: I soon started to use C++ and I don't know why comperror???Please....
Posted by Igor Pron 28 Oct 2005 17:30
sqrt(2) ==> sqrt(2.0)
Thank you very much!!! I'd reciiving :"compilation error"...
But now all O.K.! ))