Why when i submit my program with sqrt(2), it makes compilation error?(-) Could You please explain the sample to me ? -> is the diagonal multiplied by sqrt(2) ??? Explanation of sample(+) 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 ! > 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 ! > 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 ! you should use sqrtl(2) Re: Thank You very much ! 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. |