Pagini recente » Profil stay_awake77 | Cod sursa (job #2726731) | Cod sursa (job #2857848) | Cod sursa (job #3229746) | Cod sursa (job #34969)
Cod sursa(job #34969)
var c1,cn,cu:array[0..44100] of longword;
s,x,smax,i,j,k:longint;
n,m:byte;
st:array[1..21] of integer;
f:text;
procedure back;
begin
while k>0 do
begin
if k=m+1 then
begin
s:=0;
for i:=1 to m do s:=s+st[i]*i;
if s>=0 then c1[s]:=(longword(c1[s])+longword(1)) mod 10000;
dec(k);
end
else
if st[k]<1 then begin inc(st[k]); st[k+1]:=-2; inc(k); end
else dec(k);
end;
end;
begin
assign(f,'diamant.in'); reset(f);
readln(f,n,m,x);
smax:=0;
for i:=1 to n do
for j:=1 to n do smax:=smax+i*j;
close(f);
assign(f,'diamant.out'); rewrite(f);
if x>smax then writeln(f,0) else
begin
fillchar(c1,sizeof(c1),0);
s:=(m*(m+1)) div 2;
st[1]:=-2;
k:=1;
back;
{for i:=0 to s do write(c1[i],' ');}
cn:=c1;
for i:=2 to n do
begin
fillchar(cu,sizeof(cu),0);
for j:=0 to smax do
for k:= 0 to smax do
begin
cu[i*j+k]:=(cu[i*j+k]+(c1[j]*cn[k])mod 1000) mod 10000;
if i*j-k>=0 then cu[i*j-k]:=cu[i*j+k] else
cu[-i*j+k]:=cu[i*j+k];
end;
cn:=cu;
end;
writeln(f,cu[abs(x)]);
end;
close(f)
end.