ENG  RUSTimus Online Judge
Online Judge
Задачи
Авторы
Соревнования
О системе
Часто задаваемые вопросы
Новости сайта
Форум
Ссылки
Архив задач
Отправить на проверку
Состояние проверки
Руководство
Регистрация
Исправить данные
Рейтинг авторов
Текущее соревнование
Расписание
Прошедшие соревнования
Правила
вернуться в форум

Обсуждение задачи 1254. Крепкий орешек

Why when i submit my program with sqrt(2), it makes compilation error?(-)
Послано Miguel Angel 6 апр 2003 00:39
Could You please explain the sample to me ? -> is the diagonal multiplied by sqrt(2) ???
Послано uuuuuuu 6 апр 2003 01:20
Explanation of sample(+)
Послано Miguel Angel 6 апр 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 !
Послано uuuuuuu 6 апр 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 !
Послано uuuuuuu 6 апр 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 !
Послано Gheorghe Stefan 23 авг 2004 21:32
you should use sqrtl(2)
Re: Thank You very much !
Послано Yosif Yosifov 25 авг 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.