Pagini recente » Statistici Andrei Udriste (1475369147896537415369) | Rating Pricop Ana (pricopana) | Cod sursa (job #1056610) | Cod sursa (job #3263972) | Cod sursa (job #2811411)
/// hhoangcpascal
#include <iostream>
#include <algorithm>
#include <cmath>
#define llong long long
using namespace std;
int m, n;
int main() {
freopen("dreptunghiuri.in", "r", stdin);
freopen("dreptunghiuri.out", "w", stdout);
ios_base::sync_with_stdio(0); cin.tie(NULL);
cin >> m >> n; --m, --n;
llong ans = 1LL * m * (m + 1) * n * (n + 1) / 4;
for(int h = 2; h <= m; ++h) {
llong add = 0;
for(int w = 2; w <= n; ++w)
for(int a = 1; a <= h / 2; ++a) {
int C = a * (h - a);
int delta = w * w - 4 * C;
if (delta < 0) continue;
if (delta == 0) {
if (w % 2 == 0) {
add += n - w + 1;
if (a != h - a) add += n - w + 1;
}
} else {
int s = sqrt(delta);
if (s * s < delta) continue;
if ((w + s) % 2 == 0) {
add += 2 * (n - w + 1);
if (a != h - a) add += 2 * (n - w + 1);
}
}
}
ans += add * (m - h + 1);
}
cout << ans;
return 0;
}