[C103] 斐波那契数列
设 \((i,j)=gcd(i,j)\)
\[f_{i}=f_{i-1}+f_{i-2}
\]
\[f_{i}=f_{i-2}\times f_{1}+f_{i-1}\times f_{2}
\]
\[f_{i}=f_{i-1}\times f_{2}+f_{i-2}\times f_{1}
\]
\[f_{i}=(f_{i-3}+f_{i-2})\times f_{2}+f_{i-2}\times f_{1}
\]
\[f_{i}=f_{i-3}\times f_{2}+f_{i-2}\times f_{3}
\]
\[f_{i}=f_{i-k}\times f_{k-1}+F_{i-k+1}\times f_{k}
\]
\[f_{n+m}=f_{n-1}\times f_{m}+f_{n}\times f_{m+1}
\]
\[(f_{1},f_{2})=(f_{2},f_{3})=(f_{i},f_{i-1})=(f_{i}-f_{i-1},f_{i-1})=(f_{i-2},f_{i-1})=1
\]
\[f_{(i,j)}=(f_{i},f_{j})\rightarrow f_{j}\mid f_{i}=j\mid i
\]
因为 \(f_{2}=1\),则 \(f_{2}\mid 2x+1(x\in Z)\),但 \(2\nmid 2x+1 (x\in Z)\),故上述式子存在特例,且该特例唯一.
一
设 \(tot(i)\) 是 \(i\) 的约数的个数,将 \(i\) 用唯一分解定理分解为
\[i=\prod\limits_{i}p_{i}^{c_{i}}
\]
则有
\[tot(i)=\prod(c_{i}+1)
\]
那么
\[tot(i\times j)=\prod\limits_{i}p_{i}^{c_{i}}\times \prod\limits_{j}p_{j}^{c_{j}}=tot(i)\times tot(j)
\]
即 \(tot(x)\) 为 积性函数.
若质数 \(p\mid i\),则 \(min_{j}[j\mid (i\times p)]=p\),且 \(c_{p_{i}}=2\)
若质数 \(p\) 是 \(i\times p\) 的最小因子,不妨设
\[i=p^{c_{p}}\times\prod\limits_{i}p_{i}^{c_{p_{i}}}
\]
\[tot(i)=c_{p}\times \prod\limits_{i}c_{p_{i}}
\]
则
\[i\times p=p^{c_{p}+1}\times\prod\limits_{i}p_{i}^{c_{p_{i}}}
\]
\[tot(i\times p)=(c_{p}+1)\times \prod\limits_{i}c_{p_{i}}
\]
则
\[tot(i\times p)=\frac{tot(i)}{c_{p}}\times (c_{p}+1)
\]
所以我们引入 \(mintimes(i)\) 表示 \(i\) 的最小约数的 \(c_{i}\).
上述式子可以表示成
\[tot(i\times p)=\frac{tot(i)}{mintimes(i)}\times (mintimes(i)+1)
\]
上述推论对全部 \(p\in p_{i}\) 均成立
二
设 \(sqrtot(i)\) 为 \(i\) 的约数的平方和,与 \(tot(i)\) 类似,可得
\[sqrtot(x)=\prod_{i}\ \sum_{j=0}^{c_{i}}(p_{i}^{j})^{2}
\]
\[sqrtot(i\times j)=\prod_{i}\ \sum_{j=0}^{c_{i}}(p_{i}^{j})^{2}\times \prod_{i'}\ \sum_{j'=0}^{c_{i'}}(p_{i'}^{j'})^{2}=sqrtot(i)\times sqrtot(j)
\]
所以 \(sqrtot(x)\) 也为积性函数
同理,不妨设
\[p_{sum}=\sum_{j=0}^{c_{p_{i}}}(p^{j})^{2}
\]
\[sqrtot(i)=p_{sum}\times \prod_{i}\ \sum_{j=0}^{c_{i}}(p_{i}^{j})^{2}
\]
则
\[sqrtot(i\times p)=(p^{2}\times p_{sum}+1)\times \prod_{i}\ \sum_{j=0}^{c_{i}}(p_{i}^{j})^{2}
\]
维护 \(expmin(i)=p_{sum}\) 即可.