Pagini recente » Cod sursa (job #3284570) | Cod sursa (job #2577871) | Cod sursa (job #321031) | Cod sursa (job #2617300) | Cod sursa (job #2811419)
/// hhoangcpascal
#include <iostream>
#include <algorithm>
#include <cmath>
#define llong long long
using namespace std;
int m, n, ab[160006], cd[160006];
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 a = 1; a < m; ++a)
for(int b = 1; b + a <= m; ++b) ab[a*b] += (m - a - b + 1);
for(int c = 1; c < n; ++c)
for(int d = 1; c + d <= n; ++d) cd[c*d] += (n - c - d + 1);
for(int i = 1; i <= min(n * n, m * m); ++i) ans += ab[i] * cd[i];
cout << ans;
return 0;
}