bzoj 2431: [HAOI2009]逆序对数列

简单的递推。

 

const
  mm=10000;
 
var
  i,j,n,m:longint;
  f:array[0..1005,0..1005]of longint;
 
begin
  readln(n,m);
  f[1,0]:=1;
  for i:=2 to n do begin
    f[i,0]:=1;
    for j:=1 to m do begin
      f[i,j]:=f[i,j-1]+f[i-1,j];
      if j-i>=0 then f[i,j]:=(f[i,j]-f[i-1,j-i]) mod mm+mm;
      f[i,j]:=f[i,j] mod mm;
    end;
  end;
  writeln(f[n,m]);
end.
View Code

 

posted @ 2015-03-22 22:00  Macaulish  阅读(105)  评论(0编辑  收藏  举报