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

Обсуждение задачи 1001. Обратный корень

Wrong answer (C)
Послано alexanius 6 сен 2017 04:44
The tests from example and few other are ok, but it gets wrong answer in test1.

#include <math.h>
#include <stdio.h>

#define SIZE (256 * 1024) / sizeof(long long)
long long int n[SIZE + 1];

int main(void)
{
        int s = 0, l;
        do{ l = scanf("%lld", &(n[s])); s++; } while(l != EOF);
        s -= 2;

        for(;s >= 0; s--) printf("%.4Lf\n", sqrtl(n[s]));
        return 0;
}
Re: Wrong answer (C)
Послано alexanius 16 сен 2017 19:57
The problem here is that system accepts

printf("%.4f\n", sqrt(n[s]));

but does not accept

printf("%.4Lf\n", sqrtl(n[s]));

It is a bit strange because the second version is more precise. It would be great if some one showed a false test for the second variant.
Re: Wrong answer (C)
Послано Mahilewets Nikita [BSUIR] 16 сен 2017 20:09
Maybe you were printing something like 1.23456e-789?
To admins Re: Wrong answer (C)
Послано alexanius 17 сен 2017 04:33
No, L is a modifier for extended data type. To be sure I tried the following variant:

printf("%.4Lf\n", sqrt((double)n[s]));

and it passed. So the only problem is difference between sqrt and sqrtl.

To admins: I think that at least one of the tests gives different values when using sqrt and sqrtl. And more precise variant fails. Please check my guess, I think that using of both functions should be valid.