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 1075. Thread in a Space

WA test #8. Help please.
Posted by hidden_u 5 Nov 2005 00:00
What is wrong with my code? I can't figure out by myself:(

Some people talking about some tricky case. What is it?
Re: WA test #8. Help please.
Posted by Hatred 11 Feb 2010 23:41
Check your code for the extreme cases.

-1000 -1000 -1000
1000 1000 1000
0 0 0
0

I've found that sqrt returns NaN for values below 1e-8 (approximately).
Re: WA test #8. Help please.
Posted by Artem Khizha [DNU] 28 Jul 2011 02:49
Your test is incorrect, because R must be a positive integer.

> I've found that sqrt returns NaN for values below 1e-8 (approximately).
I cannot know what compiler you use, but in my GCC (and judge's MSVC) there is several functions for finding a square root:
___ float sqrtf(float);
___ double sqrt(double);
___ long double sqrtl(long double);
and the last two compute a proper value for 1e-8.


Edited by author 28.07.2011 02:49
Re: WA test #8. Help please.
Posted by Artem Khizha [DNU] 28 Jul 2011 03:54
Well, I solved a mysterious case of WA #8. :-)
Just checked every double variable whether it is NaN.

I had a working program, but get WA only because of acos function. When I had started to use something like this instead of acos:
> double arccos(double x) {
>     x = min(1.0d, max(-1.0d, x));
>     return acos(x);
> }
I got AC.
Re: WA test #8. Help please.
Posted by TeamPMI-21 26 Nov 2012 02:07
Hi. Can you explain me, why this function of arccos is working correctly?) Because our program does not accepted without it.