bzoj2154

#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的更多相关文章
- bzoj2154(莫比乌斯反演)
又是一道经典题. 1.学习了下O(n) 的做法. // // main.cpp // bzoj2154 // // Created by New_Life on 16/7/7. // Copyrigh ...
- 【BZOJ2154】Crash的数字表格(莫比乌斯反演)
[BZOJ2154]Crash的数字表格(莫比乌斯反演) 题面 BZOJ 简化题意: 给定\(n,m\) 求\[\sum_{i=1}^n\sum_{j=1}^mlcm(i,j)\] 题解 以下的一切都 ...
- BZOJ2154/BZOJ2693/Luogu1829 Crash的数字表格/JZPFAR 莫比乌斯反演
传送门--Luogu 传送门--BZOJ2154 BZOJ2693是权限题 其中JZPFAR是多组询问,Crash的数字表格是单组询问 先推式子(默认\(N \leq M\),所有分数下取整) \(\ ...
- 【bzoj2154】 Crash的数字表格
http://www.lydsy.com/JudgeOnline/problem.php?id=2154 (题目链接) 题意 给出${n,m}$,求$${\sum_{i=1}^n\sum_{j=1}^ ...
- BZOJ2154 Crash的数字表格 【莫比乌斯反演】
BZOJ2154 Crash的数字表格 Description 今天的数学课上,Crash小朋友学习了最小公倍数(Least Common Multiple).对于两个正整数a和b,LCM(a, b) ...
- bzoj2154||洛谷P1829 Crash的数字表格&&JZPTAB && bzoj3309 DZY Loves Math
bzoj2154||洛谷P1829 https://www.lydsy.com/JudgeOnline/problem.php?id=2154 https://www.luogu.org/proble ...
- 【BZOJ2693】jzptab & 【BZOJ2154】Crash的数字表格
题目 弱化版题目的传送门([BZOJ2154]Crash的数字表格) 加强版题目的传送门([BZOJ2693]jzptab) 思路&解法 题目是要求: \(\sum\limits_{i = 1 ...
- BZOJ2154: Crash的数字表格 & BZOJ2693: jzptab
[传送门:BZOJ2154&BZOJ2693] 简要题意: 给出n,m,求$\sum_{i=1}^{n}\sum_{j=1}^{m}LCM(i,j)$ 题解: 莫比乌斯反演(因为BZOJ269 ...
- Mobius反演定理-BZOJ2154
This article is made by Jason-Cow.Welcome to reprint.But please post the article's address. 莫比乌斯定理(未 ...
随机推荐
- windows server2012域服务器降级的方法
最近在一个新的网络环境里建立windows域服务器,准备建立主.备两台域服务器.在一台新服务器上面安装了windows2012R2并配置了DC服务.域和林的级别设置为Windows2012R2级别.在 ...
- MYSQL存储过程和函数学习笔记
学至Tarena金牌讲师,金色晨曦科技公司技术总监沙利穆课程笔记的综合. 1. 什么是存储过程和函数 将SQL语句放入一个集合里,然后直接调用存储过程和函数来执行已经定义好的SQL语句,通过存储过程和 ...
- Vbox中Ubuntu的安装和共享文件夹设置
1. 选择版本 1.1 Ubuntu桌面版与服务器版的区别 桌面版与服务器版,只要发布版本号一致,这两者从核心来说也就是相同的,唯一的差别在于它们的预期用途.桌面版面向个人电脑使用者,可以进行文字处理 ...
- 让 Dreamweaver 支持 Emmet(原ZenCoding)
注:目前暂不支持 DW CC,期待作者早是更新.Update:2013/10/12 鉴于某些原因,每个 Coder 所钟爱的 IDE 各不相同.而作为一个软件爱好者,我几乎所有 IDE 都使用过一段时 ...
- Android摇一摇振动效果Demo
前言 在微信刚流行的时候,在摇一摇还能用来那啥的时候,我也曾深更半夜的拿着手机晃一晃.当时想的最多的就是.我靠,为神马摇一下须要用这么大的力度,当时我想可能腾讯认为那是个人性的设计.后来才发觉 ...
- iscc2016 mobile1-TurtleShell.apk解题过程
拿到程序先运行,简单的验证输入的flag正确与否.jeb加载apk文件 实在库文件里面验证,所以ida加载之,so文件是加密的,所以看不到关键验证函数,百度搜了下libhackme.so,出来这篇文章 ...
- mysql 数据库 备份 还原
参考资料: http://blog.51yip.com/mysql/139.html
- Linux系统中C&Cpp程序开发(一)
之前一直在Windows系统下进行程序的设计,近期开始学习使用Linux系统,因而打算将程序开发也转移到Linux系统下.今天先简单介绍一下该系统下的C程序开发步骤. 首先要预先安装vim和gcc工具 ...
- js精度丢失解决办法
/** * 加法运算,避免数据相加小数点后产生多位数和计算精度损失. * * @param num1加数1 | num2加数2 */ function numAdd(num1, num2) { var ...
- 代码段编辑器SnippetEditor 2.1
1.选择程序版本 2.可以创建文件夹 3.新建片段 4.给片段取名 5.双击进行编辑 6.点击保存 7.直接使用