Pagini recente » Cod sursa (job #2695741) | Cod sursa (job #1355497) | Cod sursa (job #1526361) | Cod sursa (job #789487) | Cod sursa (job #2711663)
#include <bits/stdc++.h>
#define sqr(x) ((x) * (x))
using namespace std;
ifstream fin("dreptunghiuri.in");
ofstream fout("dreptunghiuri.out");
const int VMAX = 1e5 + 6e4 + 1;
int N, M, rad[VMAX];
long long ans;
int main() {
fin >> N >> M;
for(int i = 1; i < VMAX; ++i)
rad[i] = sqrt(i);
for(int h = 1; h < N; ++h)
for(int w = 1; w < M; ++w) {
int cnt = 1;
for(int k = 1; k < h; ++k) {
int delta = sqr(w) - 4 * k * (h - k);
if(delta == 0 && w % 2 == 0)
++cnt;
else
if(delta > 0 && delta == rad[delta] * rad[delta] && (w + rad[delta]) % 2 == 0 && w > rad[delta])
cnt += 2;
}
ans += cnt * (N - h) * (M - w);
}
fout << ans << '\n';
}