#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. iOS-网络编程(二)文件上传和断点离线下载

    一. iOS中发送HTTP请求的方案 在iOS中,我们常用发送HTTP请求的方案有苹果原生(自带)NSURLConnection:用法简单,最古老最经典最直接的一种方案 (iOS 9.0弃用)NSUR ...

  2. Jenkins - 持续集成

    Jenkins是一个开源软件项目,旨在提供一个开放易用的软件平台,使持续集成变成可能. Jenkins,之前叫做Hudson,是基于Java开发的一种持续集成工具,用于监控秩序重复的工作,包括: 1. ...

  3. Nicholas C. Zakas(JS圣经:JavaScript高级程序设计作者)如何面试前端工程师

    Original Post:Interviewing the front-end engineerNicholas C. Zakas,2010年1月5日翻译完成:2010年1月7日,最后更新:2010 ...

  4. Linux编程环境介绍(2) -- shell(Bash) 介绍

    1. 在计算机科学中,Shell俗称壳(用来区别于核),是指“提供使用者使用界面”的软件(命令解析器).它类似于DOS下的command和后来的cmd.exe. 2. bash (Bourne Aga ...

  5. Cycling Label

    Cycling Label 来源: github/BBCyclingLabel Licence: Apache 2.0 作者: Bruno de Carvalho 分类: 标签(Label) 平台: ...

  6. Android(java)学习笔记262:JNI之工具快速开发步骤

    下面通过一个案例说明一下,利用工具jni快速开发步骤 1.新建一个Android工程,命名为"03_对int数组加1",如下: 2. 在MainActivity.java中对add ...

  7. hdu 2032

    水题 AC代码: #include <stdio.h> int main() { int a[31][31]; int i,j,n; a[1][1]=a[2][1]=a[2][2]=1; ...

  8. JSP Servlet SQL 三者之间数据传递

    前言: 最近一直在做WEB开发,现总结一下这一段时间的体会和感触. 切记,web开发重点在于前台数据交互,页面美化而不要太沉溺于底层数据. 浏览器时代来到,向我们召唤出更炫.更简洁.更方便.更大气的网 ...

  9. 【转】C++中的位拷贝与值拷贝

    [转]http://blog.csdn.net/liam1122/article/details/1966617 为了便于说明我们以String类为例: 首先定义String类,而并不实现其成员函数. ...

  10. CentOS7.1 使用资源搜集

    1.配置java环境 -openjdk* 测试 java -version 2.安装Tomcat8.0.35 点击题目可以参考源网页,但有些代码无法执行,更改如下(亲测可行): 一定要先安装java环 ...