Pagini recente » Cod sursa (job #822994) | Cod sursa (job #1975895) | Cod sursa (job #953122) | Cod sursa (job #139284) | Cod sursa (job #2132806)
#include <bits/stdc++.h>
using namespace std;
ifstream fi("dreptunghiuri.in");
ofstream fo("dreptunghiuri.out");
using i64 = long long;
const int N = 405;
i64 ant, l, n, m;
int main() {
fi >> n >> m;
ant = n * (n - 1) * m * (m - 1) / 4;
for (i64 x = 1; x <= n; ++x)
for (i64 y = 1; y <= m; ++y) if (x || y) {
l = min((n - y) / x, (m - x) / y) - 1;
if (l > 0) {
ant+= l * (m * n - n * x - y * m + x * y);
ant+= l * (l + 1) / 2 * (x * x + y * y - n * y - m * x);
ant+= l * (l + 1) * (2 * l + 1) / 6 * x * y; } }
fo << ant << endl;
return 0; }