Pagini recente » Cod sursa (job #21005) | Cod sursa (job #1430133) | Cod sursa (job #622691) | Cod sursa (job #2489927) | Cod sursa (job #2736995)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("dreptunghiuri.in");
ofstream fout("dreptunghiuri.out");
const int VTMAX(16010);
int rad[VTMAX];
int main()
{
int n, m;
fin >> n >> m;
for(int i = 1; i <= VTMAX - 5; ++i)
rad[i] = sqrt(i);
long long rez = 0;
for(int h = 1; h < n; ++h)
for(int w = 1; w < n; ++w)
{
int cnt = 1;
for(int a = 1; a < h; ++a){
int dlt = w * w - 4 * a * (h - a);
if(dlt == 0 && w % 2 == 0)
++cnt;
else if(dlt > 0 && dlt == rad[dlt] * rad[dlt] && (w + rad[dlt]) % 2 == 0 && w > rad[dlt])
cnt += 2;
}
rez += cnt * (n - h) * (m - w);
}
fout << rez << '\n';
return 0;
}