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 1254. Die Hard

Why when i submit my program with sqrt(2), it makes compilation error?(-)
Posted by Miguel Angel 6 Apr 2003 00:39
Could You please explain the sample to me ? -> is the diagonal multiplied by sqrt(2) ???
Posted by uuuuuuu 6 Apr 2003 01:20
Explanation of sample(+)
Posted by Miguel Angel 6 Apr 2003 02:56
It tells
1 1
1 3
4 1
4 3
Then you will go from
(1,1)->(2,1)->(3,2)->(2,3)->(1,3) = 2 + 2*sqrt(2) /*two diagonals*/
(1,3)->(2,3)->(3,2)->(4,1) = 1 + 2*sqrt(2)        /*two diagonals*/
(4,1)->(4,2)->(4,3) = 2
Add up this distance and divide by V, you'll get the answer.
But i use:

#include<math.h>

const double sqrt2 = sqrt(2);

and makes me Compile Error :(, so just change for a numerical one and
get AC.
Thank You ery much !
Posted by uuuuuuu 6 Apr 2003 12:21
> It tells
> 1 1
> 1 3
> 4 1
> 4 3
> Then you will go from
> (1,1)->(2,1)->(3,2)->(2,3)->(1,3) = 2 + 2*sqrt(2) /*two diagonals*/
> (1,3)->(2,3)->(3,2)->(4,1) = 1 + 2*sqrt(2)        /*two diagonals*/
> (4,1)->(4,2)->(4,3) = 2
> Add up this distance and divide by V, you'll get the answer.
> But i use:
>
> #include<math.h>
>
> const double sqrt2 = sqrt(2);
>
> and makes me Compile Error :(, so just change for a numerical one
and
> get AC.
Thank You very much !
Posted by uuuuuuu 6 Apr 2003 12:21
> It tells
> 1 1
> 1 3
> 4 1
> 4 3
> Then you will go from
> (1,1)->(2,1)->(3,2)->(2,3)->(1,3) = 2 + 2*sqrt(2) /*two diagonals*/
> (1,3)->(2,3)->(3,2)->(4,1) = 1 + 2*sqrt(2)        /*two diagonals*/
> (4,1)->(4,2)->(4,3) = 2
> Add up this distance and divide by V, you'll get the answer.
> But i use:
>
> #include<math.h>
>
> const double sqrt2 = sqrt(2);
>
> and makes me Compile Error :(, so just change for a numerical one
and
> get AC.
Re: Thank You very much !
Posted by Gheorghe Stefan 23 Aug 2004 21:32
you should use sqrtl(2)
Re: Thank You very much !
Posted by Yosif Yosifov 25 Aug 2004 02:32
Or .. you should use a "static_cast" it can be done easily this way :
const double sqrt2 = sqrt((double)2);

because sqrt , takes an arugment type double. I hope I helped.