Cod sursa(job #71377)

Utilizator cezar305Mr. Noname cezar305 Data 10 iulie 2007 13:33:33
Problema Diamant Scor 100
Compilator fpc Status done
Runda Arhiva de probleme Marime 1.28 kb
var v,t:array[-45000..45000]of longint;
    x:array[0..1000]of longint;
    i,j,n,m,c,s:longint;

begin
assign(input,'diamant.in');reset(input);
assign(output,'diamant.out');rewrite(output);
readln(n,m,c);
for i:=1 to n do
        for j:=1 to m do
                begin
                s:=s+i*j;
                inc(x[0]);
                x[x[0]]:=i*j;
                end;
if (c>s)or(c<-s) then
        begin
        writeln(0);
        close(output);
        halt;
        end;
v[0]:=1;
t[0]:=1;
for i:=1 to x[0] do
        begin
        for j:=-s to s do
                if (t[j]<>0){((t[j]=0)or((v[j]>1)))} then
                        begin
                        if (x[i]+j<=s)and(x[i]+j>=-s) then
                                begin
                                inc(v[x[i]+j],t[j]);
                                v[x[i]+j]:=v[x[i]+j] mod 10000;
                                end;
                        if (-x[i]+j<=s)and(-x[i]+j>=-s) then
                                begin
                                inc(v[-x[i]+j],t[j]);
                                v[-x[i]+j]:=v[-x[i]+j] mod 10000;
                                end;
                        end;
        t:=v;
        end;
writeln(v[c] mod 10000);
close(input);close(output);
end.