VTRI - Triangles
Tác giả: ladpro98
Ngôn ngữ: Pascal
program vtri;
uses math;
const fi='';
var x,y,s,t,res,res2,c,i,j:longint;
factor:array[1..500] of longint;
inp:text;
procedure input;
begin
assign(inp,fi);
reset(inp);
readln(inp,x,y,s);
close(inp);
end;
procedure init;
begin
t:=1;
for i:=1 to s do
begin
if s mod i = 0 then begin
factor[t]:=i;
inc(t);
end;
end;
dec(t);
end;
begin
input;
s:=s*2;
init;
res:=0;
res2:=0;
for i:=0 to x do
for j:=0 to y do
for c:=1 to t do
begin
if (i+factor[c])<=x then
begin
if j+(s div factor[c]) <=y then
begin
inc(res,x-1);
inc(res2,1);
end;
if j-(s div factor[c]) >= 0 then
begin
inc(res,x-1);
inc(res2);
end;
end;
if (i-factor[c])>=0 then
begin
if j+(s div factor[c])<=y then
begin
inc(res,x-1);
inc(res2);
end;
if j-(s div factor[c])>=0 then begin
inc(res,x-1);
inc(res2);
end;
end;
if (j+factor[c])<=y then
begin
if (i+(s div factor[c])<=x) then
begin
inc(res,y-1);
inc(res2);
end;
if (i-(s div factor[c])>=0) then
begin
inc(res,y-1);
inc(res2);
end;
end;
if (j-factor[c])>=0 then
begin
if (i+(s div factor[c]))<=x then
begin
inc(res,y-1);
inc(res2);
end;
if (i-(s div factor[c]))>=0 then
begin
inc(res,y-1);
inc(res2);
end;
end;
end;
write((res+res2) div 2);
end.