You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

18 lines
408 B
C++

//http://blog.csdn.net/popoqqq/article/details/39924877
#include <cstdio>
long long f[100100], ans;
int main()
{
int m, n, k;
scanf("%d%d", &m, &n);
k = (m < n ? m : n);
for (int i = k; i; i--)
{
f[i] = 1ll * (m / i) * (n / i);
for (int j = 2; j * i <= k; j++)
f[i] -= f[i * j];
ans += f[i] * (i + i - 1);
}
printf("%lld", ans);
return 0;
}