Pagini recente » Statistici AndreiG (Andrei_G) | Cod sursa (job #533053) | Profil andrici_cezar | Cod sursa (job #2464840) | Cod sursa (job #2379)
Cod sursa(job #2379)
{$q-,r-,s-,d-,i-}
const maxn=400;
var t:Text;
N,M,X,Y,a,delta,acum:longint;sol:int64;
Rad:array[0..maxn*maxn]of longint;
begin
assign(t,'dreptunghiuri.in');reset(t);readln(t,x,y);close(T);dec(x);dec(y);
if x>y then begin a:=x;x:=y;y:=a;end;for a:=0 to maxn do Rad[a*a]:=a;
for n:=1 to X do for m:=n to Y do
begin
acum:=1;
for a:=1 to n-1 do
begin
delta:=m*m-a*(n-a)shl 2;
if delta<0 then continue;
if delta=0 then begin inc(acum);continue;end;
delta:=rad[delta];
if (delta=0)or ((m+delta)and 1=1) then continue;
if m>delta then inc(acum,2);
end;
sol:=sol+acum*(x-n+1)*(y-m+1);
{ writeln(n,' ',m,' ',acum*(x-n+1)*(y-m+1),' ',sol);}
if (m<=X)and(m<>n) then
begin
sol:=sol+acum*(y-n+1)*(x-m+1);
{ writeln(m,' ',n,' ',acum*(y-n+1)*(x-m+1),' ',sol);}
end;
end;
assign(t,'dreptunghiuri.out');rewrite(T);writeln(t,sol);close(T);
end.