# n div i有2√n个取值

https://blog.csdn.net/gmh77/article/details/88142031

# n div (n div x)=x (x≤√n)

$$n=ax+b（0≤b<x）$$
$$\left \lfloor \frac{n}{\left \lfloor \frac{n}{x} \right \rfloor} \right \rfloor=x$$
$$\left \lfloor \frac{ax+b}{\left \lfloor \frac{ax+b}{x} \right \rfloor} \right \rfloor=x$$
$$\left \lfloor \frac{ax+b}{a} \right \rfloor=x$$
$$\left \lfloor x+\frac{b}{a} \right \rfloor=x$$

$$a>b$$

（用于min25筛）

# 平方求和公式

$$\sum_{i=1}^{n}{i^2}$$

$$=\frac{1}{2}\sum_{i=1}^{n}{n^2-i^2+i+n}$$
$$=\frac{1}{2}(n^2(n+1)+\frac{1}{2}(1+n)n-\sum_{i=1}^{n}{i^2})$$
$$=\frac{1}{2}(n(n+1)(n+\frac{1}{2})-\sum_{i=1}^{n}{i^2})$$

$$\sum_{i=1}^{n}{i^2}=\frac{1}{2}(n(n+1)(n+\frac{1}{2})-\sum_{i=1}^{n}{i^2})$$
$$2\sum_{i=1}^{n}{i^2}=n(n+1)(n+\frac{1}{2})-\sum_{i=1}^{n}{i^2}$$
$$3\sum_{i=1}^{n}{i^2}=n(n+1)(n+\frac{1}{2})$$
$$\sum_{i=1}^{n}{i^2}=\frac{n(n+1)(n+\frac{1}{2})}{3}$$
$$\sum_{i=1}^{n}{i^2}=\frac{n(n+1)(2n+1)}{6}$$

# 调和级数公式

https://blog.csdn.net/gmh77/article/details/98226712
$$\sum_{i=1}^{n}{\frac{1}{i}}=\ln(n)+\gamma+X_n$$（γ为欧拉常数，当n趋近与无穷大时Xn约等于0）

$$\sum_{i=1}^{n}{\frac{1}{i}}=\int_{1}^{n+1}{\frac{1}{\left \lfloor x \right \rfloor}}dx$$
$$=\int_{1}^{n+1}{\frac{1}{x}}dx+\int_{1}^{n+1}{(\frac{1}{\left \lfloor x \right \rfloor}-\frac{1}{x})}dx$$
$$=\ln(n+1)+\int_{1}^{n+1}{(\frac{1}{\left \lfloor x \right \rfloor}-\frac{1}{x})}dx$$
$$=\ln(n)+\gamma+X_n$$（n+1≈∞）
$$\approx \ln(n)+\gamma$$（n+1≈∞）

## 欧拉常数计算

#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#define fo(a,b,c) for (a=b; a<=c; a++)
#define fd(a,b,c) for (a=b; a>=c; a--)
#define E 0.0001
using namespace std;

long double euler,i;

int main()
{
i=1;

while (i<=10000)
{
euler+=(1.0/floor(i)-1.0/i);
i+=E;
}

printf("%0.10Lf\n",euler*E);
}


# 斐波那契数列性质

https://blog.csdn.net/gmh77/article/details/98583079
$$gcd(F(n-1),F(n))=1$$
$$F(n)=F(m+1)F(n-m)+F(m)F(n-m-1)$$
$$gcd(F(n),F(m))=F(gcd(n,m)$$

$$F(n)=F(m)F(n-m+1)+F(m-1)F(n-m)$$
$$F(n)=F(m)F(n-m)+F(m)F(n-m-1)+F(m-1)F(n-m)$$
$$F(n)=(F(m)+F(m-1))F(n-m)+F(m)F(n-m-1)$$
$$F(n)=F(m+1)F(n-m)+F(m)F(n-m-1)$$

$$gcd(F(n),F(m))=gcd(F(m+1)F(n-m)+F(m)F(n-m-1),F(m))$$
$$gcd(F(n),F(m))=gcd((F(m+1)F(n-m)+F(m)F(n-m-1))\; mod \;F(m),F(m))$$

$$gcd(F(n),F(m))=gcd(F(n-m),F(m))$$

（这个式子对多个数也是成立的）

# 欧拉函数性质

https://blog.csdn.net/gmh77/article/details/99066792
$$n=\sum_{d|n}{\varphi(d)}$$
$$F(n)=\sum_{d|n}{\varphi(d)}$$，则
$$F(n)*F(m)=\sum_{i|n}{\varphi(i)}*\sum_{j|m}{\varphi(j)}$$（nm互质）
$$=\sum_{i|n}{\sum_{j|m}{\varphi(i*j)}}$$
$$=F(n*m)$$

$$F(p^k)$$（p为质数）
$$F(p^k)=\sum_{i=0}^{k}{\varphi(p^i)}$$
$$=(\sum_{i=1}^{k}{p^i*(1-\frac{1}{p})})+1$$
$$=(\sum_{i=1}^{k}{p^{i-1}*(p-1)})+1$$
$$=(\sum_{i=1}^{k}{p^i-p^{i-1}})+1$$
$$=p^k-p^0+1$$
$$=p^k$$

$$F(n)=\sum_{d|n}{\varphi(d)}$$
$$n=\sum_{d|n}{\varphi(d)}$$

# $$\sum_{gcd(i,n)=1}i=\frac{1}{2}\varphi(n)n$$

n=2时刚好满足（巧合），n=1要特判

# $$\sum_{i=1}^{k}{i\binom{k}{i}}=2^{k-1}k$$

$$i\binom{k}{i}=i*\frac{k!}{i!(k-i)!}=k*\frac{(k-1)!}{(i-1)!(k-i)!}=\binom{k-1}{i-1}$$

σ0是约数个数

# 斐波那契通项公式

https://www.cnblogs.com/gmh77/p/13387949.html

# $$\varphi(ab)=\varphi(a)\varphi(b)*\frac{(a,b)}{\varphi((a,b))}$$

posted @ 2019-09-07 20:05  gmh77  阅读(362)  评论(0编辑  收藏  举报