比赛 20111111 评测结果 AWAAAAAAAA
题目名称 最优分解方案 最终得分 90
用户昵称 lizhe 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2011-11-11 11:25:29
显示代码纯文本
program best;
type
  node=record
    x:array[1..500]of longint
  end;
var
  n,i,j,k,t,num:longint;
  max:node;
  w:array[0..1001]of longint;
procedure init;
begin
  assign(input,'best.in');
  reset(input);
  assign(output,'best.out');
  rewrite(output);
  read(n);
  for i:=1 to n do
    w[i]:=w[i-1]+i
end;

procedure mul(a:node;b:longint; var c:node);
var
  l,jin,len:longint;
  d:node;
begin
  len:=num;
  for l:=1 to num+1 do
    d.x[l]:=0;
  for l:=1 to num do
  begin
    d.x[l]:=d.x[l]+a.x[l]*b;
    if d.x[l]>=10 then
    begin
      d.x[l+1]:=d.x[l] div 10;
      d.x[l]:=d.x[l] mod 10;
      if len<l+1 then len:=l+1
    end
  end;
  if d.x[len]>=10 then
  begin
    d.x[len+1]:=d.x[len] div 10;
    d.x[len]:=d.x[len] mod 10;
    inc(len)
  end;
  for l:=1 to len do
    c.x[l]:=d.x[l];
  num:=len
end;

procedure main;
begin
  for i:=2 to n do
    if w[i]-w[1]>=n then
    begin
      k:=i;
      break
    end;
  t:=w[i]-w[1]-n;
  max.x[1]:=1;
  num:=1;
  if t=0 then
    for i:=2 to k do
      mul(max,i,max);
  if t=1 then
  begin
    mul(max,k+1,max);
    for i:=2 to k-1 do
      mul(max,i,max)
  end;
  if t>=2 then
  begin
    for i:=2 to k do
      if i<>t then
        mul(max,i,max)
  end
end;


procedure print;
begin
  for i:=num downto 1 do
    write(max.x[i]);
  writeln;
  close(input);
  close(output)
end;

begin
  init;
  main;
  print
end.