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

Обсуждение задачи 1402. Коктейли

WA20
Послано Dmitrij 8 май 2012 00:21
Can anyone explain me, why this code got WA20:
program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  f : array[1..21] of extended;
  d, c : array[-1..21, -1..21] of extended;
  res : extended;
  i, j, k, n : integer;

begin

  readln(n);
  res := 0;
  f[1] := 1;
  for i := 2 to n do
    f[i] := f[i - 1] * i;
  c[0][0] := 1;
  for i := 1 to n do
    for j := 0 to i do
      c[i][j] := c[i - 1][j] + c[i - 1][j - 1];
  for i := 2 to n do
    res := res + c[n][i] * f[i];

  writeln(res:0:0);

  readln;readln;
end.

But this code got AC:
program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  n : integer;
  s : array[1..21] of string;

begin

  s[1] := '0';
  s[2] := '2';
  s[3] := '12';
  s[4] := '60';
  s[5] := '320';
  s[6] := '1950';
  s[7] := '13692';
  s[8] := '109592';
  s[9] := '986400';
  s[10] := '9864090';
  s[11] := '108505100';
  s[12] := '1302061332';
  s[13] := '16926797472';
  s[14] := '236975164790';
  s[15] := '3554627472060';
  s[16] := '56874039553200';
  s[17] := '966858672404672';
  s[18] := '17403456103284402';
  s[19] := '330665665962403980';
  s[20] := '6613313319248079980';
  s[21] := '138879579704209680000';

  readln(n);
  writeln(s[n]);

end.

In spite of the fact, that answers for second programm I took as the results of the first program :)

Edited by author 08.05.2012 00:24
Re: WA20
Послано Andrew Sboev 8 май 2012 23:38
Simple school maths. Just one formula from combinatorics. Without any precalc.

Edited by author 08.05.2012 23:38
Re: WA20
Послано Dmitrij 13 май 2012 11:53
This is not my question.I couldn't understend why writeln(res:0:0) got WA, but on all my tests it's OK.Now I think it's becouse of old version of compiler here.