#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<utility>
#include<set>
#include<bitset>
#include<vector>
#include<functional>
#include<deque>
#include<cctype>
#include<climits>
#include<complex> using namespace std; typedef long long LL;
typedef double DB;
typedef pair<int,int> PII;
typedef complex<DB> CP; #define mmst(a,v) memset(a,v,sizeof(a))
#define mmcy(a,b) memcpy(a,b,sizeof(a))
#define re(i,a,b) for(i=a;i<=b;i++)
#define red(i,a,b) for(i=a;i>=b;i--)
#define fi first
#define se second
#define m_p(a,b) make_pair(a,b)
#define SF scanf
#define PF printf
#define two(k) (1<<(k)) template<class T>inline T sqr(T x){return x*x;}
template<class T>inline void upmin(T &t,T tmp){if(t>tmp)t=tmp;}
template<class T>inline void upmax(T &t,T tmp){if(t<tmp)t=tmp;} const DB EPS=1e-;
inline int sgn(DB x){if(abs(x)<EPS)return ;return(x>)?:-;}
const DB Pi=acos(-1.0); inline int gint()
{
int res=;bool neg=;char z;
for(z=getchar();z!=EOF && z!='-' && !isdigit(z);z=getchar());
if(z==EOF)return ;
if(z=='-'){neg=;z=getchar();}
for(;z!=EOF && isdigit(z);res=res*+z-'',z=getchar());
return (neg)?-res:res;
}
inline LL gll()
{
LL res=;bool neg=;char z;
for(z=getchar();z!=EOF && z!='-' && !isdigit(z);z=getchar());
if(z==EOF)return ;
if(z=='-'){neg=;z=getchar();}
for(;z!=EOF && isdigit(z);res=res*+z-'',z=getchar());
return (neg)?-res:res;
} const LL maxN=10000000LL;
const LL Mod=20101009LL; LL N,M;
LL ans; LL mu[maxN+],sum[maxN+];
LL prime[maxN+],tol;
bool isnotprime[maxN+];
inline void prepare()
{
LL i,j;
mu[]=;
re(i,,N)
{
if(!isnotprime[i]){mu[i]=-;prime[++tol]=i;}
for(j=;j<=tol && prime[j]*i<=N;j++)
{
isnotprime[prime[j]*i]=;
if(i%prime[j]==){mu[prime[j]*i]=;break;}
mu[prime[j]*i]=-mu[i];
}
}
re(i,,N) sum[i]=(sum[i-]+(mu[i]*i*i)%Mod)%Mod;
} inline LL F(LL x,LL y)
{
LL res=,e,last;
for(e=;e<=x;e=last+)
{
last=min(x/(x/e),y/(y/e));
upmin(last,x);
LL s=(sum[last]-sum[e-])%Mod;
LL t=((+(x/e))*(x/e)/%Mod)*((+(y/e))*(y/e)/%Mod)%Mod;//记住要多加括号
res=(res+s*t%Mod)%Mod;
}
return res;
} int main()
{
freopen("bzoj2154.in","r",stdin);
freopen("bzoj2154.out","w",stdout);
N=gll();M=gll();
if(N>M)swap(N,M);
prepare();
ans=;
LL d,last;
for(d=;d<=N;d=last+)
{
last=min(N/(N/d),M/(M/d));
upmin(last,N);
LL s=(d+last)*(last-d+)/%Mod;
LL t=F(N/d,M/d);
ans=(ans+s*t%Mod)%Mod;
}
ans=(ans%Mod+Mod)%Mod;
cout<<ans<<endl;
return ;
}
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<utility>
#include<set>
#include<bitset>
#include<vector>
#include<functional>
#include<deque>
#include<cctype>
#include<climits>
#include<complex> using namespace std; typedef long long LL;
typedef double DB;
typedef pair<int,int> PII;
typedef complex<DB> CP; #define mmst(a,v) memset(a,v,sizeof(a))
#define mmcy(a,b) memcpy(a,b,sizeof(a))
#define re(i,a,b) for(i=a;i<=b;i++)
#define red(i,a,b) for(i=a;i>=b;i--)
#define fi first
#define se second
#define m_p(a,b) make_pair(a,b)
#define SF scanf
#define PF printf
#define two(k) (1<<(k)) template<class T>inline T sqr(T x){return x*x;}
template<class T>inline void upmin(T &t,T tmp){if(t>tmp)t=tmp;}
template<class T>inline void upmax(T &t,T tmp){if(t<tmp)t=tmp;} const DB EPS=1e-;
inline int sgn(DB x){if(abs(x)<EPS)return ;return(x>)?:-;}
const DB Pi=acos(-1.0); inline int gint()
{
int res=;bool neg=;char z;
for(z=getchar();z!=EOF && z!='-' && !isdigit(z);z=getchar());
if(z==EOF)return ;
if(z=='-'){neg=;z=getchar();}
for(;z!=EOF && isdigit(z);res=res*+z-'',z=getchar());
return (neg)?-res:res;
}
inline LL gll()
{
LL res=;bool neg=;char z;
for(z=getchar();z!=EOF && z!='-' && !isdigit(z);z=getchar());
if(z==EOF)return ;
if(z=='-'){neg=;z=getchar();}
for(;z!=EOF && isdigit(z);res=res*+z-'',z=getchar());
return (neg)?-res:res;
} const LL Mod=20101009LL;
const LL maxN=10000000LL; LL N,M; LL f[maxN+];
LL prime[maxN+],tol;
bool isnotprime[maxN+]; inline void prepare()
{
f[]=;
LL i,j;
re(i,,N)
{
if(!isnotprime[i]){prime[++tol]=i;f[i]=-i;}
for(j=;j<=tol && i*prime[j]<=N;j++)
{
isnotprime[i*prime[j]]=;
if(i%prime[j]==)
{
f[i*prime[j]]=f[i];
break;
}
f[i*prime[j]]=f[i]*f[prime[j]]%Mod;
}
}
} int main()
{
freopen("bzoj2154.in","r",stdin);
freopen("bzoj2154.out","w",stdout);
LL i;
N=gll();M=gll();
if(N>M)swap(N,M);
prepare();
LL ans=;
re(i,,N)
{
LL res=i;
res=res*((+(N/i))*(N/i)/%Mod)%Mod;
res=res*((+(M/i))*(M/i)/%Mod)%Mod;
res=res*f[i]%Mod;
ans=(ans+res)%Mod;
}
ans=(ans%Mod+Mod)%Mod;
cout<<ans<<endl;
return ;
}
来自:http://maijing3007.blog.163.com/blog/static/246120003201545101527359