[bzoj4176]Lucas的数论
来源:互联网 发布:电脑智能机器人软件 编辑:程序博客网 时间:2024/05/16 10:33
Orz w_yqts
Orz xudyh
Orz popoqqq
求
首先证明
若有
则素数p对左式d(nm)的贡献为k1+k2+1
对于右式则有
贡献也是k1+k2+1
所以等号成立
直接把这个式子代进去反演一下就好了……?
μ的部分用杜教筛做…
#include <bits/stdc++.h>using namespace std;#define p 1000000007#define ll long long#define N 2500000map <int,int> f;int pn,pr[N],flag[N],miu[N];int n;inline int sqr(int x){ return (ll)(x)*x%p;}inline int calc(int n){ int res=0; for (int i=1,pos;i<=n;i=pos+1) { pos=n/(n/i); res+=(ll)(pos-i+1)*(n/i)%p; res%=p; } return res;}inline int calcmiu(int n){ if (n<N) return miu[n]; if (f[n]) return f[n]; int res=1; for (int i=2,pos;i<=n;i=pos+1) { pos=n/(n/i); res-=calcmiu(n/i)*(pos-i+1); } return f[n]=res;}void init(){ miu[1]=flag[1]=1; for (int i=2;i<N;++i) { if (!flag[i]) pr[++pn]=i,miu[i]=-1; for (int j=1;j<=pn && i*pr[j]<N;++j) { flag[i*pr[j]]=1; if (i%pr[j]==0) {miu[i*pr[j]]=0;break;} miu[i*pr[j]]=-miu[i]; } } for (int i=1;i<N;++i) miu[i]+=miu[i-1];}inline int mobius(int n){ int res=0; for (int i=1,pos;i<=n;i=pos+1) { pos=n/(n/i); res+=(ll)(calcmiu(pos)-calcmiu(i-1))*sqr(calc(n/i))%p; res%=p; } return (res+p)%p;}main(){ init(); cin>>n; //for (int i=1;i<=n;++i) cout<<miu[i]<<' ';cout<<endl; cout<<mobius(n)<<endl;}
阅读全文
0 0
- bzoj4176 Lucas 的数论
- [bzoj4176]Lucas的数论
- [杜教筛] BZOJ4176. Lucas的数论
- bzoj4176 Lucas的数论 (杜教筛 +莫比乌斯反演)
- 4176: Lucas的数论
- bzoj 4176 Lucas的数论
- BZOJ 4176 Lucas的数论
- 【BZOJ 4176】 Lucas的数论 - 杜教筛
- 一道水题---lucas的数论
- bzoj 4176: Lucas的数论 (反演)
- lucas数论定理学习
- 数论 Lucas定理 hdu3037
- 数论--Lucas Theorem
- 数论总结之Lucas
- lucas (数论定理)
- BZOJ 4176 Lucas的数论 莫比乌斯反演
- bzoj 4176 Lucas的数论 莫比乌斯反演
- [杜教筛 约数个数前缀和] BZOJ 4176 Lucas的数论
- [BZOJ2303]-[Apio2011]方格染色-并查集+题目性质
- Android Studio出现Failed to open zip file问题的解决方法
- 原生js 操作dom
- 第七章:函数、第八章:数组
- tracert命令使用
- [bzoj4176]Lucas的数论
- 一步步搭建Retrofit+RxJava+MVP网络请求框架(一)
- 遍历list时删除元素的正确做法
- 关于HTTP
- QT控件大全 二十八 QMultiYearCalender
- 队列操作的实现-链式存储
- LintCode 第423题
- Model Tree Structures with Nested Sets
- 阿里云前端周刊