#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

bzoj2154的更多相关文章

  1. bzoj2154(莫比乌斯反演)

    又是一道经典题. 1.学习了下O(n) 的做法. // // main.cpp // bzoj2154 // // Created by New_Life on 16/7/7. // Copyrigh ...

  2. 【BZOJ2154】Crash的数字表格(莫比乌斯反演)

    [BZOJ2154]Crash的数字表格(莫比乌斯反演) 题面 BZOJ 简化题意: 给定\(n,m\) 求\[\sum_{i=1}^n\sum_{j=1}^mlcm(i,j)\] 题解 以下的一切都 ...

  3. BZOJ2154/BZOJ2693/Luogu1829 Crash的数字表格/JZPFAR 莫比乌斯反演

    传送门--Luogu 传送门--BZOJ2154 BZOJ2693是权限题 其中JZPFAR是多组询问,Crash的数字表格是单组询问 先推式子(默认\(N \leq M\),所有分数下取整) \(\ ...

  4. 【bzoj2154】 Crash的数字表格

    http://www.lydsy.com/JudgeOnline/problem.php?id=2154 (题目链接) 题意 给出${n,m}$,求$${\sum_{i=1}^n\sum_{j=1}^ ...

  5. BZOJ2154 Crash的数字表格 【莫比乌斯反演】

    BZOJ2154 Crash的数字表格 Description 今天的数学课上,Crash小朋友学习了最小公倍数(Least Common Multiple).对于两个正整数a和b,LCM(a, b) ...

  6. bzoj2154||洛谷P1829 Crash的数字表格&&JZPTAB && bzoj3309 DZY Loves Math

    bzoj2154||洛谷P1829 https://www.lydsy.com/JudgeOnline/problem.php?id=2154 https://www.luogu.org/proble ...

  7. 【BZOJ2693】jzptab & 【BZOJ2154】Crash的数字表格

    题目 弱化版题目的传送门([BZOJ2154]Crash的数字表格) 加强版题目的传送门([BZOJ2693]jzptab) 思路&解法 题目是要求: \(\sum\limits_{i = 1 ...

  8. BZOJ2154: Crash的数字表格 & BZOJ2693: jzptab

    [传送门:BZOJ2154&BZOJ2693] 简要题意: 给出n,m,求$\sum_{i=1}^{n}\sum_{j=1}^{m}LCM(i,j)$ 题解: 莫比乌斯反演(因为BZOJ269 ...

  9. Mobius反演定理-BZOJ2154

    This article is made by Jason-Cow.Welcome to reprint.But please post the article's address. 莫比乌斯定理(未 ...

随机推荐

  1. java 枚举类型

    原来枚举类型还可以这样玩... public enum Tenum { None(1),ByteArray(2),List(3),Map(4); private int id; private Ten ...

  2. 你需要知道的九大排序算法【Python实现】之快速排序

    五.快速排序 基本思想:  通过一趟排序将待排序记录分割成独立的两部分,其中一部分记录的关键字均比另一部分关键字小,则分别对这两部分继续进行排序,直到整个序列有序. 算法实现: ​ #coding: ...

  3. Javascript:getElementsByClassName

    背景: 由于原生的getElementsByClassName不支持在指定标签中查找指定元素为指定class的情况,所以,这里舍弃了原生的方法调用   方法一: function getElement ...

  4. parcel write boolean值

    http://stackoverflow.com/questions/6201311/how-to-read-write-a-boolean-when-implementing-the-parcela ...

  5. coco2d-html5制作弹弓射鸟第一部分---橡皮筋

    一.写在前面的话 最近在学习cocos2d-html5方面的知识,一直想从事游戏方面的工作,自己也找了好多资料.网上关于cocos2d-html5的教程真的不多,也只有自己摸索,慢慢看示例代码.由于本 ...

  6. ansible 学习与实践

    title: ansible 学习与实践 date: 2016-05-06 16:17:28 tags: --- ansible 学习与实践 一 介绍 ansible是新出现的运维工具是基于Pytho ...

  7. Linux 创建swap分区

    --首先分出一个分区 /dev/sda5 (注意分区类型)mkswap /dev/sda5           --格式化分区成swap格式swapon /dev/sda5           --激 ...

  8. Android推送等耗电原因剖析

    原文链接:http://www.jianshu.com/p/584707554ed7 Android手机有两个处理器,一个是Application Processor(AP)基于ARM处理器,主要运行 ...

  9. SQL Server系统表讲解

    1. sysobjects http://www.cnblogs.com/atree/p/SQL-Server-sysobjects.html   2.syscomments http://www.c ...

  10. php+js 瀑布流源码

    官方网站:更多源码 新浪微博:QQ公众号 QQ:各种源码 602902342 大牛技术群: 452207697 下载地址:http://pan.baidu.com/s/1bnNipI3 密码: h93 ...