Pagini recente » Cod sursa (job #1379799) | Cod sursa (job #217786) | Cod sursa (job #2341232) | Cod sursa (job #480218) | Cod sursa (job #2594366)
#include <bits/stdc++.h>
#define DIM 170000
using namespace std;
ifstream fin ("dreptunghiuri.in");
ofstream fout ("dreptunghiuri.out");
int n,m,i,j,k;
int root[DIM];
int main (){
fin>>n>>m;
memset (root,-1,sizeof root);
for (i=0;i<=m;i++)
root[i*i] = i;
long long sol = 0;
for (i=1;i<n;++i)
for (j=1;j<m;++j){
/// fixez un punct de pe latime
int cnt = 1;
for (int k=1;k<i;++k){
int b = -j;
int c = k * i - k * k;
int delta = b*b - 4*c;
if (delta < 0)
continue;
int val = root[delta];
if (val < 0)
continue;
int x1 = j + val, x2 = j - val;
if ( (x1&1) == 0 && (x1>>1) > 0 && (x1>>1) < j)
++cnt;
if (delta && (x2&1) == 0 && (x2>>1) > 0 && (x2>>1) < j)
++cnt;
}
sol += 1LL * cnt * (n-i) * (m-j);
}
fout<<sol;
return 0;
}