简单的递推。
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.