[反演 数论] 51Nod 1355 斐波那契的最小公倍数
来源:互联网 发布:苹果手机九格切图软件 编辑:程序博客网 时间:2024/05/12 20:47
我好菜啊 出过一万遍的原题 我怎么第一次看见啊
某乎链接
按照zyz的做法 orzz
令
由于
所以
实际上
#include<cstdio>#include<cstdlib>#include<algorithm>using namespace std;typedef long long ll;inline char nc(){ static char buf[100000],*p1=buf,*p2=buf; return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;}inline void read(int &x){ char c=nc(),b=1; for (;!(c>='0' && c<='9');c=nc()) if (c=='-') b=-1; for (x=0;c>='0' && c<='9';x=x*10+c-'0',c=nc()); x*=b;}const int maxn=1000000;const int P=1e9+7;inline ll Pow(ll a,int b){ ll ret=1; for (;b;b>>=1,a=a*a%P) if (b&1) ret=ret*a%P; return ret;}inline ll Inv(ll a){ return Pow(a,P-2);}ll f[maxn+5],g[maxn+5];inline void Pre(int n){ f[0]=0; f[1]=1; for (int i=2;i<=n;i++) f[i]=(f[i-1]+f[i-2])%P; for (int i=1;i<=n;i++) g[i]=f[i]; for (int i=2;i<=n;i++){ ll inv=Inv(g[i]); for (int j=i+i;j<=n;j+=i) (g[j]*=inv)%=P; }}const int N=50005;int n,a[maxn+5];int main(){ int x; freopen("t.in","r",stdin); freopen("t.out","w",stdout); Pre(maxn); read(n); for (int i=1;i<=n;i++) read(x),a[x]=1; ll ans=1; for (int i=1;i<=maxn;i++){ int t=0; for (int j=i;j<=maxn && !t;j+=i) t|=a[j]; if (t) ans=ans*g[i]%P; } printf("%d\n",ans); return 0;}
阅读全文
0 0
- [反演 数论] 51Nod 1355 斐波那契的最小公倍数
- 51nod 1355 斐波那契的最小公倍数 (数论+莫比乌斯反演)
- [莫比乌斯反演] 51Nod 1355 斐波那契的最小公倍数
- 51nod 1355 斐波那契的最小公倍数 莫比乌斯反演+数学
- 51nod 1355 斐波那契的最小公倍数
- 51nod 1355 斐波那契的最小公倍数
- 51Nod-1355-斐波那契的最小公倍数
- 51Nod 1355 斐波那契的最小公倍数
- [数论 斐波那契] 51nod1355. 斐波那契的最小公倍数
- 20140911 【 初等数论 】 51nod 1242 . 斐波那契数列的第N项
- [数论][莫比乌斯反演][杜教筛] 51Nod 1238 最小公倍数之和 V3
- [数论][莫比乌斯反演] 51Nod 1222 最小公倍数计数
- 1355 斐波那契的最小公倍数
- 51Nod->1419最小公倍数挑战 (数论)
- 51Nod->1419最小公倍数挑战 (数论)
- 51nod 1012 最小公倍数LCM【数论】
- [51nod1355]斐波那契的最小公倍数
- 51nod1355 斐波那契的最小公倍数
- [LeetCode] 138. Copy List with Random Pointer
- web.xml基础详解
- 5-51 两个有序链表序列的合并 (20分)
- Jackson系统给您介绍何为娱乐文化优先股!
- 漫步数理统计三十四——顺序统计量
- [反演 数论] 51Nod 1355 斐波那契的最小公倍数
- TensorFlow学习笔记之读取数据概述
- Lintcode78 Longest Common On Prefix solution 题解
- Android自动化测试-Monkey性能测试
- ElasticSearch学习
- 10张图带你深入理解Docker容器和镜像
- Struts2 action
- pkg-config命令了解和使用
- 【剑指offer】题15:链表倒数第k个节点