Pagini recente » Cod sursa (job #2335283) | Cod sursa (job #371882) | Cod sursa (job #2124060) | Cod sursa (job #2454861) | Cod sursa (job #914307)
Cod sursa(job #914307)
#include<cstdio>
#define ok(x) ((x)%2==0 && (x)/2>=0 && (x)/2<b)
static short sqrt[405*405+5];
int _calc (int b,int c)
{
int d=b*b-4*c;
if(d==0)
return ok (b);
else if(d>0 && sqrt[d])
return ok (b-sqrt[d]) + ok (b+sqrt[d]);
return 0;
}
#define calc(a) _calc (w, (a)*(h-(a)))*(m-w)*(n-h)
int main (void)
{
freopen ("dreptunghiuri.in","r",stdin);
#ifdef INFOARENA
freopen ("dreptunghiuri.out","w",stdout);
#endif
for(int i=1;i<=405;i++)
sqrt[i*i]=i;
int m,n;
long long ret=0;
scanf ("%d%d",&m,&n);
for(int w=1;w<m;w++)
for(int h=1;h<n;h++){
for(int a=0;a<=h/2;a++)
ret+=calc (a)*2;
if(h%2==0)
ret-=calc (h/2);
ret-=calc (h);
}
printf ("%lld",ret);
return 0;
}