Cod sursa(job #940435)

Utilizator rudarelLup Ionut rudarel Data 16 aprilie 2013 11:22:19
Problema Diamant Scor 80
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.83 kb
const ct=10000;
var f:text;
    c1,cn:array[-44100..44100] of integer;
    v:array[1..400] of integer;
    smax,n,m,i,j,k,x,p:longint;
 
 
begin
assign(f,'diamant.in'); reset(f);
readln(f,n,m,x);
smax:=0;
p:=0;
for i:=1 to n do
 for j:=1 to m do
  begin
  inc(p);
  v[p]:=i*j;
  smax:=smax+v[p];
  end;
close(f);
assign(f,'diamant.out'); rewrite(f);
if (x<-smax) or (smax<x) then writeln(f,0)
 else
  begin
  c1[-1]:=1;
  c1[0]:=1;
  c1[1]:=1;
  for k:=2 to p do
  begin
   fillchar(cn,sizeof(cn),0);
   for j:=-smax to smax do
    if c1[j]>0 then
    begin
     cn[j]:=(longword(cn[j])+longword(c1[j]))mod ct;
     cn[j-v[k]]:=(longword(cn[j-v[k]])+longword(c1[j]))mod ct;
     cn[j+v[k]]:=(longword(cn[j+v[k]])+longword(c1[j]))mod ct;
     end;
  c1:=cn;
  end;
 writeln(f,c1[x]);
 end;
close(f);
end.