double gets TLE and long double AC, why?

Revision en2, by VLamarca, 2019-02-19 23:02:50

Hi,

regarding problem B from this contest, my solution using double gets TLE and the same solution using long double gets AC, anyone has any idea why?

You can use this test case in custom invocation to confirm that the solution using long double is indeed twice faster.

EDIT: I could pinpoint the problem and it is the mod member function that gets the norm of a vector using hypot(x,y), which is the same as sqrt(x*x+y*y) but with better precision. The solution with double gets accepted if I use double everywhere, casting to long double only here: hypot((long double)x,y) (code). Using sqrt(x*x+y*y) instead works too. Nonetheless it is still very strange that hypot function is faster when dealing with long double.

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English VLamarca 2019-02-19 23:02:50 498 Tiny change: 'aster.\n\nEDIT: I could p' -> 'aster.\n\n**EDIT:** I could p'
en1 English VLamarca 2019-02-19 05:35:55 463 Initial revision (published)