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

Обсуждение задачи 1371. Грузоперевозки

Precision question
Послано Samsonov Alex [USU] 16 сен 2005 17:09
What precision should we use in output?

Could I have WA#17 because of it?

Is double (long double) enough for us?
Re: Precision question
Послано Vladimir Yakovlev (USU) 16 сен 2005 21:44
with a precision of 4 decimal digits.

double is always enough for calculatings on Timus.
Re: Precision question
Послано Samsonov Alex [USU] 16 сен 2005 23:09
Then it (4 digits) should be written in russian statement.
Fixed. (-)
Послано Vladimir Yakovlev (USU) 17 сен 2005 00:29
Re: Precision question
Послано Igor Dex 7 окт 2005 01:32
To avoid precision problems it is possible to use only integer numbers in solving this task, but I have the same WA#17.
Re: Precision question
Послано Burunduk1 7 окт 2005 23:54
Do you use int64? Check it.
(50 000 * 50 000 = 2 500 000 000)
Re: Precision question
Послано Igor Dex 8 окт 2005 02:06
Yes, of cause, I use unsigned __int64.
Re: Precision question
Послано Samsonov Alex [USU] 9 окт 2005 18:27
I tried double, __in64 and long double and still WA17. That must be some other bug...
Re: Precision question
Послано Antonov Yuri (USU) 10 окт 2005 00:02
Maybe problem with the following code:

for ( i = 1; i <= m_N; ++i )
for ( j = 1; j <= m_N; ++j )
sum += t[ i ][ j ];

sum /= N * (N - 1);

It must be obviously changed to ...
for ( i = 1; i <= m_N; ++i )
for ( j = 1; j <= m_N; ++j )
sum += t[ i ][ j ]) / ( N * (N - 1));

overflow ...

Maybe it will be usefull :- )
Re: Precision question
Послано Samsonov Alex [USU] 10 окт 2005 21:58
And again I've tried both variants... Still WA17
Re: Precision question
Послано Antonov Yuri (USU) 10 окт 2005 22:44
Why both variants! First fragment implyies WA ( it`s obvious )
Did you convert N to __int64 ? It was noted that N*N > signed int.

Hmmm ... Send me your code ( see e-mail in my profile )
Re: Precision question
Послано Samsonov Alex [USU] 23 окт 2005 21:59
Yes. The bug what in these data types. I think I should love __int64 from this task and further. Thank you very much! I got AC.
Re: Precision question
Послано Denis Koshman 19 авг 2008 03:56
I used __int64 (signed) to get total sum of all paths. Then I casted it to double before division by n*(n-1)/2. Got WA41. That happened because 'n' was 'int' and that multiplication overflowed. Then I casted 'n' to 'int64' inside that multiplication and got AC.