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

here is the trick!
Posted by gush(gu_shenhua@yahoo.com.cn) 28 Jul 2003 22:00
this may be true: 1.000 > 1.
so add this func:
    double acos1(double x)
    {
        if(x > 1)
          x = 1;
        if(x < -1)
          x = -1;
        return acos(x);
    }
Re: here is the trick!
Posted by Fly [Yaroslavl_SU] 29 Sep 2005 00:47
BIG thanks!!!
Re: here is the trick!
Posted by Zhihua Lai 29 May 2007 22:50
Big thanks, god, without that, my program was stopped at test 8.
Re: here is the trick!
Posted by Denis Koshman 3 Aug 2008 11:33
It's actually 1.00000000000000001, not 1.000

BTW, same stuff should be applied to 'sqrt'. if(v<0 && v>-eps) v = 0; sqrt(v);
Re: here is the trick!
Posted by Oracle[Lviv NU] 9 Jan 2009 00:22
THANKS!!!!!!!!!!
It really helped me! After small fix - AC :)
Re: here is the trick!
Posted by Enzo 10 Jun 2010 08:10
thanks so much, i got ac with your func...
Re: here is the trick!
Posted by MishaRash 31 Jul 2015 13:15
Thank you very much! I had WA 24, "safe" acos didn't help, but "safe" sqrt did, I got AC. I used it so:
double sqrt1(double a) {
  if (a<0)
    return 0;
  return sqrt(a);
}

Edited by author 31.07.2015 13:17
Re: here is the trick!
Posted by Tbilsu_Irakli Khomeriki 17 Sep 2018 20:09
thanks a lot, never would have figured out :)