Pagini recente » Cod sursa (job #2776156) | Cod sursa (job #1104400) | Cod sursa (job #1854465) | Cod sursa (job #2998764) | Cod sursa (job #2713345)
// https://imgur.com/a/94tjMUh
#include <bits/stdc++.h>
#define dbg() cerr <<
#define name(x) (#x) << ": " << (x) << ' ' <<
using namespace std;
int C2(int n) {
return n * (n - 1) / 2;
}
int main() {
ifstream cin("dreptunghiuri.in");
ofstream cout("dreptunghiuri.out");
int n, m; cin >> n >> m;
vector<int> choose_xy(n * n);
for (int x = 1; x < n; ++x) {
for (int y = 1; x + y <= n; ++y) {
choose_xy[x * y] += n - x - y;
}
}
vector<int> choose_zt(m * m);
for (int z = 1; z < n; ++z) {
for (int t = 1; z + t <= m; ++z) {
choose_zt[z * t] += m - z - t;
}
}
int ans = 0;
int lim = min(n * n, m * m);
for (int i = 1; i < lim; ++i) {
ans += choose_xy[i] * choose_zt[i];
}
ans += C2(n) * C2(m);
cout << ans << endl;
}