5 4

36

# HINT

#include<iostream>
#include<cstdio>
#include<cstdlib>
using namespace std;

typedef long long ll;
#define maxn 100010
int n,m,tot,prime[maxn],mu[maxn];
bool exist[maxn]; ll ans;

inline void find()
{
mu[1] = 1;
for (int i = 2;i <= n;++i)
{
if (!exist[i]) prime[++tot] = i,mu[i] = -1;
for (int j = 1;j <= tot&&i*prime[j]<=n;++j)
{
exist[i*prime[j]] = true;
if (i % prime[j] == 0) { mu[i*prime[j]] = 0; break; }
mu[i*prime[j]] = -mu[i];
}
}
for (int i = 1;i <= n;++i) mu[i] += mu[i-1];
}

inline ll calc(int a,int b,int d)
{
a /= d; b /= d;
ll ret = 0; int pos;
for (int i = 1;i <= a;i = pos+1)
{
pos = min(a/(a/i),b/(b/i));
ret += (ll)(mu[pos]-mu[i-1])*(ll)(a/i)*(ll)(b/i);
}
return ret;
}

int main()
{
freopen("2005.in","r",stdin);
freopen("2005.out","w",stdout);
scanf("%d %d",&n,&m); if (n > m) swap(n,m);
find();
for (int i = 1;i <= n;++i)
ans += (ll)((i<<1)-1)*calc(n,m,i);
printf("%lld",ans);
fclose(stdin); fclose(stdout);
return 0;
}

posted @ 2015-07-08 20:06  lmxyy  阅读(150)  评论(0编辑  收藏  举报