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

Обсуждение задачи 1443. Рельсы

why WA#20
Послано Tbilisi SU: Andrew Lutsenko 27 мар 2006 20:23
Please give me some tests. I just can't find a mistake
Re: why WA#20
Послано 6y 27 мар 2006 22:34
The deal in the accuracy. I had WA#20 too but I replace this in my program
ost=s-a*l;
with
ost=(s*10000-a*l*10000)/10000;
s,a,l - double
Re: why WA#20
Послано Tbilisi SU: Andrew Lutsenko 30 мар 2006 21:25
THANX!!! I've got AC. This is an interesting artefact. In FreePascal I had wa even when i've added multiplying on 10000. Then in C++ it worked. Thank you once more.
Re: why WA#20
Послано xMagGTU Дмитрий Тишкин GPRS 31 мар 2006 01:20
you method reading data not good better this:
read line as string s
remove '.'
convert to long!
that all.
in other algo you know..
You know, it is your method which is bad. Sure, it is better to multiply the numbers by 10000 (-)
Послано Dmitry 'Diman_YES' Kovalioff 31 мар 2006 01:28
Re: You know, it is your method which is bad. Sure, it is better to multiply the numbers by 10000 (-)
Послано SPIRiT 4 май 2006 18:16
Strange, I did this thing, but got WA. I used the same trick with Conductors problem (1011) and was lucky. Are you sure that it's just enough to multiply numbers, convert them in long and use them (I assume we're discussing the C++ realisation).
Re: You know, it is your method which is bad. Sure, it is better to multiply the numbers by 10000 (-)
Послано Michael Medvedev 9 окт 2006 01:30
I used here long double, but it didn't help here.
I multiplied by 1000 as it was said here, but WA

Can smbd give data for this test 20?
Re: why WA#20
Послано Crash_access_violation 26 дек 2007 18:38
This is my code... but I got wa#20 :( ...

TYPE
 ReaL = Double;

VAR
 N : integer;
 Ans, S, L : ReaL;

PROCEDURE Run;
 Var
  Res, Q : ReaL;
  i : integer;
   Begin
    ReadLn(N);
    ReadLn(S);
    ReadLn(L);
    Ans := N * Int(S / L);
    Q := (S * 10000 - ((Ans / N) * L * 10000)) / 10000;
    Res := 0;
    i := 0;
     while (i < N) and (Q > 0) do
      begin
       inc(i);
        if (Res * 10000 - Q * 10000) / 10000 < 0 then
          begin
           Ans := Ans + 1;
           Res := (L * 10000) / 10000;
          end;
       Res := (Res * 10000 - Q * 10000) / 10000;
      end;
    WriteLn(Ans : 0 : 0);
   End;

BEGIN
  Run;
END.
Re: You know, it is your method which is bad. Sure, it is better to multiply the numbers by 10000 (-)
Послано Denis Koshman 10 авг 2008 14:34
I solved it using 'int' type in C++

#define THR (1e-8)

int n;
double ss, ll;
scanf("%d %lf %lf", &n, &ss, &ll);
int s = (int)(ss*10000 + THR);
int l = (int)(ll*10000 + THR);

printf("%d\n", f(n, s, l));