#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
typedef long long LL;
inline int read()
{
int x=0;bool f=0;char c=getchar();
for (;c<'0'||c>'9';c=getchar()) f=c=='-'?1:0;
for (;c>='0'&&c<='9';c=getchar()) x=x*10+c-'0';
return f?-x:x;
}
const int N=10000010,mod=20101009;
int A,B,n,pr[N],pc=0,g[N],ans=0;
bool np[N];
inline int F(int x)
{
int da=A/x,db=B/x;
da=(LL)da*(da+1)/2%mod;
db=(LL)db*(db+1)/2%mod;
return (LL)da*db%mod;
}
inline int add(int a,int b)
{
a+=b;
if (a>=mod) a-=mod;
return a;
}
int main()
{
A=read();B=read();n=min(A,B);
g[1]=1;
for (int i=2;i<=n;i++)
{
if (!np[i]) pr[++pc]=i,g[i]=1-i;
for (int j=1,k=i<<1;j<=pc&&k<=n;k=i*pr[++j])
{
np[k]=1;
if (i%pr[j]==0) {g[k]=g[i];break;}
g[k]=g[i]*(1-pr[j]);
}
}
for (int i=1;i<=n;i++) g[i]=(LL)g[i]*i%mod;
for (int i=1;i<=n;i++) g[i]=(g[i]+g[i-1]+(mod<<1))%mod;
for (int i=1,pos;i<=n;i=pos+1)
{
pos=min(A/(A/i),B/(B/i));
ans=add(ans,(LL)(g[pos]-g[i-1]+mod)*F(i)%mod);
}
printf("%d\n",ans);
return 0;
}
bzoj2154【莫比乌斯函数】【线性筛】
最新推荐文章于 2020-09-19 00:25:36 发布