\(\mathcal{Description}\)

  Link.

  令 \(f\) 为 \(\text{Fibonacci}\) 数列,给定 \(\{a_n\}\),求:

\[\operatorname{lcm}\{f_{a_1},f_{a_2},\cdots,f_{a_n}\}\bmod(10^9+7)
\]

  \(n\le5\times10^4\),\(a_i\le10^6\)。

\(\mathcal{Solution}\)

  你得知道:

\[\gcd(f_i,f_j)=f_{\gcd(i,j)}\tag1
\]
\[\operatorname{lcm}(S)=\prod_{T\subseteq S\land T\not=\varnothing}\gcd(T)^{(-1)^{|T|+1}}\tag2
\]

  \((1)\) 老经典的结论了;\((2)\) 本质上是一个 \(\text{Min-Max}\) 反演。

  记 \(F=\{f_{a_n}\},S=\{a_n\},m=\max(S)\),开始推导:

\[\begin{aligned}
\operatorname{lcm}(F)&=\prod_{T\subseteq F\land T\not=\varnothing}\gcd(T)^{(-1)^{|T|+1}}\\
&=\prod_{T\subseteq S\land T\not=\varnothing}f_{\gcd(T)}^{(-1)^{|T|+1}}\\
&=\prod_{d=1}^mf_d^{\sum_{T\subseteq S\land T\not=\varnothing\land\gcd(T)=d}(-1)^{|T|+1}}
\end{aligned}
\]

  记 \(f_d\) 的指数为 \(g(d)\),令 \(h(d)=\sum_{T\subseteq S\land T\not=\varnothing\land d|\gcd(T)}(-1)^{|T|+1}=1-\sum_{T\subseteq S\land d|\gcd(T)}(-1)^{|T|}\)。设有 \(c_d\) 个 \(a_x\) 是 \(d\) 的倍数,那么:

\[\sum_{T\subseteq S\land d|\gcd(T)}(-1)^{|T|}=\sum_{s=0}^{c_d}\binom{c_d}s(-1)^s
\]

  二项式展开逆用,后式为 \((1-1)^{c_d}=[c_d=0]\),所以 \(h(d)=[c_d\not=0]\)。最后利用 \(h\) 反演出 \(g\):

\[g(d)=\sum_{d|n}h(n)\mu(\frac{n}d)
\]

  \(\mathcal O(n\ln n)\) 把 \(g\) 求出来就好。

\(\mathcal{Code}\)

/* Clearink */

#include <cstdio>

inline int rint () {
int x = 0; int f = 1; char s = getchar ();
for ( ; s < '0' || '9' < s; s = getchar () ) f = s == '-' ? -f : f;
for ( ; '0' <= s && s <= '9'; s = getchar () ) x = x * 10 + ( s ^ '0' );
return x * f;
} inline void wint ( int x ) {
if ( 9 < x ) wint ( x / 10 );
putchar ( x % 10 ^ '0' );
} const int MAXN = 5e4, MAXA = 1e6, MOD = 1e9 + 7;
int pn, pr[MAXA + 5], mu[MAXA + 5];
int n, a[MAXN + 5], fib[MAXA + 5], indx[MAXA + 5];
bool buc[MAXA + 5], vis[MAXA + 5]; inline int qkpow ( int a, int b, const int p = MOD ) {
int ret = 1; b = ( b % ( p - 1 ) + ( p - 1 ) ) % ( p - 1 );
for ( ; b; a = 1ll * a * a % p, b >>= 1 ) ret = 1ll * ret * ( b & 1 ? a : 1 ) % p;
return ret;
} inline void init ( const int n ) {
mu[1] = 1;
for ( int i = 2; i <= n; ++ i ) {
if ( !vis[i] ) mu[pr[++ pn] = i] = -1;
for ( int j = 1, t; j <= pn && ( t = i * pr[j] ) <= n; ++ j ) {
vis[t] = true;
if ( !( i % pr[j] ) ) break;
mu[t] = -mu[i];
}
}
fib[1] = 1;
for ( int i = 1; i <= n; ++ i ) {
if ( i > 1 ) fib[i] = ( fib[i - 1] + fib[i - 2] ) % MOD;
for ( int j = i; j <= n; j += i ) {
buc[i] |= buc[j];
}
}
for ( int i = 1; i <= n; ++ i ) {
for ( int j = 1, t = n / i; j <= t; ++ j ) {
indx[i] += mu[j] * buc[i * j];
}
}
} int main () {
n = rint ();
int mxa = 0;
for ( int i = 1; i <= n; ++ i ) {
buc[a[i] = rint ()] = true;
if ( mxa < a[i] ) mxa = a[i];
}
init ( mxa );
int ans = 1;
for ( int i = 1; i <= mxa; ++ i ) {
ans = 1ll * ans * qkpow ( fib[i], indx[i] ) % MOD;
}
wint ( ans ), putchar ( '\n' );
return 0;
}

\(\mathcal{Details}\)

  对 \(\text{Min-Max}\) 要敏感一点呐……

Solution -「51nod 1355」斐波那契的最小公倍数的更多相关文章

  1. 【51nod 1355】 斐波那契数的最小公倍数

    题目 51nod的数学题都还不错啊 首先直接算显然是没有办法算的,因为\(fib\)的lcm这个东西还是太鬼畜了 我们考虑到\(fib\)数列的一个非常好的性质是\(gcd(fib_i,fib_{j} ...

  2. POJ 3070 + 51Nod 1242 大斐波那契数取余

    POJ 3070 #include "iostream" #include "cstdio" using namespace std; class matrix ...

  3. 【51nod1355】斐波那契的最小公倍数(min-max容斥)

    [51nod1355]斐波那契的最小公倍数(min-max容斥) 题面 51nod 题解 显然直接算还是没法算的,所以继续考虑\(min-max\)容斥计算. \[lcm(S)=\prod_{T\su ...

  4. LOJ 3184: 「CEOI2018」斐波那契表示法

    题目传送门:LOJ #3184. 题意简述: 题目说得很清楚了. 题解: 首先需要了解「斐波那契数系」为何物. 按照题目中定义的斐波那契数列 \(F_n\),可以证明,每个非负整数 \(n\) 都能够 ...

  5. 「洛谷P1306」斐波那契公约数 解题报告

    P1306 斐波那契公约数 题目描述 对于Fibonacci数列:1,1,2,3,5,8,13......大家应该很熟悉吧~~~但是现在有一个很"简单"问题:第n项和第m项的最大公 ...

  6. 51nod 1355 - 斐波那契的最小公倍数(Min-Max 容斥+莫比乌斯反演)

    vjudge 题面传送门 首先我们知道斐波那契数列的 lcm 是不太容易计算的,但是它们的 gcd 非常容易计算--\(\gcd(f_x,f_y)=f_{\gcd(x,y)}\),该性质已在我的这篇博 ...

  7. 51Nod——T 1242 斐波那契数列的第N项

    https://www.51nod.com/onlineJudge/questionCode.html#!problemId=1242 基准时间限制:1 秒 空间限制:131072 KB 分值: 0  ...

  8. [51nod1355] 斐波那契的最小公倍数

    Description 给定 \(n\) 个正整数 \(a_1,a_2,...,a_n\),求 \(\text{lcm}(f_{a_1},f_{a_2},...,f_{a_n})\).其中 \(f_i ...

  9. Solution -「51nod 1514」美妙的序列

    \(\mathcal{Description}\)   Link.   称排列 \(\{p_n\}\) 美妙,当且仅当 \((\forall i\in[1,n))(\max_{j\in[1,i]}\{ ...

随机推荐

  1. 解决ubuntu18.04重启后蓝牙鼠标需要重新配对的问题

    打开bash,运行bluetoothctl命令 # bluetoothctl 列出可用的蓝牙控制器 [bluetooth]# list 选择使用的蓝牙控制器 [bluetooth]# select 0 ...

  2. 第10组 Alpha冲刺 (4/6)

    1.1基本情况 ·队名:今晚不睡觉 ·组长博客:https://www.cnblogs.com/cpandbb/p/13982696.html ·作业博客:https://edu.cnblogs.co ...

  3. JavaWeb中Cookie会话管理,理解Http无状态处理机制

    注:图片如果损坏,点击文章链接:https://www.toutiao.com/i6512995108961387015/ 1.<Servlet简单实现开发部署过程> 2.<Serv ...

  4. Angularjs实现下拉列表排序

    <select class="form-control underline" ng-model="reportform.score" ng-options ...

  5. [WPF] 用 Effect 实现线条光影效果

    1. 前言 几个月前 ChokCoco 大佬发布了一篇文章: CSS 奇技淫巧 | 妙用 drop-shadow 实现线条光影效果 在文章里实现了一个发光的心形线条互相追逐的效果: 现在正好有空就试试 ...

  6. 【C】C语言大作业——学生学籍管理系统

    文章目录 学生管理系统 界面 主界面 登陆界面 注册界面 管理界面 学生界面 退出界面 链接 注意 学生管理系统 学C语言时写的一个大作业,弄了一个带图形界面的,使用的是VS配合EasyX图形库进行实 ...

  7. 5.14-HTTP间通信

    1.社长社员通信WEBSOCKET WebSocket 是一种标准协议,用于在客户端和服务端之间进行双向数据传输.但它跟 HTTP 没什么关系,它是一种基于 TCP 的一种独立实现. 以前客户端想知道 ...

  8. 【练习】rust中的复制语义和移动语义

    1.基本类型都是复制语义的 fn main(){ let a = 123; { #[allow(unused_variables)] let b = a; //如果是移动语义,那么后续的a将不再有效 ...

  9. 【记录一个问题】云风的协程库 c conroutine无法在android下链接通过

    链接出现以下错误: coroutine.c:139: undefined reference to `getcontext' coroutine.c:146: undefined reference ...

  10. 使用Cesium的地下渲染技术可视化瑞士的地质资源

    Cesium中文网:http://cesiumcn.org/ | 国内快速访问:http://cesium.coinidea.com/ Camptocamp为瑞士拓扑的孪生数字增加了地下可视化功能. ...