[数论 斐波那契] 51nod1355. 斐波那契的最小公倍数
来源:互联网 发布:强矩阵 编辑:程序博客网 时间:2024/05/23 23:06
进入斐波那契领域的第一题…
不要脸地截图了Manchery的博客……原文在这里
#include <cstdio>#include <iostream>#include <algorithm>using namespace std;const int N=1000010,P=1e9+7;int n,x,ans=1,f[N],vis[N],g[N];int gcd(int x,int y){ return y?gcd(y,x%y):x;}inline int Pow(int x,int y){ int ret=1; for(;y;y>>=1,x=1LL*x*x%P) if(y&1) ret=1LL*ret*x%P; return ret;}int main(){ scanf("%d",&n); f[1]=f[2]=1; g[1]=g[2]=1; for(int i=3;i<=N-10;i++) g[i]=f[i]=(f[i-1]+f[i-2])%P; for(int i=1;i<=N-10;i++){ int INV=Pow(g[i],P-2); for(int j=i+i;j<=N-10;j+=i) g[j]=1LL*g[j]*INV%P; } for(int i=1;i<=n;i++) scanf("%d",&x),vis[x]=1; for(int i=1;i<=N-10;i++){ int t=0; for(int j=i;j<=N-10 && !t;j+=i) if(vis[j]) t=1; if(t) ans=1LL*ans*g[i]%P; } printf("%d\n",ans); return 0;}
阅读全文
0 0
- [数论 斐波那契] 51nod1355. 斐波那契的最小公倍数
- [51nod1355]斐波那契的最小公倍数
- 51nod1355 斐波那契的最小公倍数
- [反演 数论] 51Nod 1355 斐波那契的最小公倍数
- 51nod 1355 斐波那契的最小公倍数 (数论+莫比乌斯反演)
- 1355 斐波那契的最小公倍数
- 51nod 1355 斐波那契的最小公倍数
- 51nod 1355 斐波那契的最小公倍数
- 51Nod-1355-斐波那契的最小公倍数
- 51Nod 1355 斐波那契的最小公倍数
- 数论-斐波那契数列
- nefu 115 斐波那契的整除(数论)
- NEFU115 斐波那契的整除(数论水题)
- <数论> NEFU 115 斐波那契的整除
- nefu115 斐波那契的整除(数论,整除推导)
- [莫比乌斯反演] 51Nod 1355 斐波那契的最小公倍数
- 51nod 1355 斐波那契的最小公倍数 莫比乌斯反演+数学
- java求最大公约数,最小公倍数,斐波那契数列
- JavaScript里的Boolean
- 学习嵌入式Linux系统开发基础 第四课(Shell的使用)
- Google 开源的 Android 排版库:FlexboxLayout
- C++继承权限问题讲解最全面的
- CSS-同一个li下,图片和文字一起,如何使得全部垂直居中
- [数论 斐波那契] 51nod1355. 斐波那契的最小公倍数
- VS2010版快捷键
- js作用域
- 【Linux学习笔记】33:环境变量配置文件简介
- 机器学习和计算机视觉库
- 【Java基础】概述
- [POI2000]病毒 [洛谷]P2444
- Codeforces849A Odds and Ends
- 利用Python创建链接mysql数据库个性化对象