数论整理(upd:2021.10.7)

数论

by AmanoKumiko

1.扩欧

\[ax+by=1 \]

\[ax+by=gcd(a,b) \]

\[ax+by=gcd(b,a\ mod\ b) \]

\[ax+by=bx1+(a-b\lfloor\frac{a}{b}\rfloor)y1 \]

\[ax+by=bx1+ay1-b\lfloor\frac{a}{b}\rfloor·y1 \]

\[ax+by=ay1+b(x1-\lfloor\frac{a}{b}\rfloor·y1) \]

\[x=y1,y=x1-\lfloor\frac{a}{b}\rfloor·y1 \]

2.逆元

(1)

\[ax≡1(mod\ p) \]

(2)

\[ax+by=1 \]

(3)

\[k=\lfloor\frac{p}{i}\rfloor,r=p\ mod\ i \]

\[ki+r≡0(mod\ p) \]

\[kr^{-1}+i^{-1}≡0(mod\ p) \]

\[i^{-1}≡-kr^{-1}(mod\ p) \]

\[i^{-1}≡-\lfloor\frac{p}{i}\rfloor·(p\ mod\ i)^{-1}(mod\ p) \]

3.φ

(1)

\[n'=\frac{n}{p1} \]

\[p1\mid n' \]

\[φ(n)=p1·φ(n') \]

\[p1\nmid n' \]

\[φ(n)=(p1-1)·φ(n') \]

(2)

\[n=\sum_{d|n}φ(d) \]

(3)

\[\sum_{i=1}^{n}[gcd(i,n)=1]i=\sum_{i=1}^{n}\sum_{d|gcd(i,n)}μ(d)i \]

\[=\sum_{d|n}μ(d)\sum_{i=1}^{\frac{n}{d}}di \]

\[=\sum_{d|n}μ(d)d\frac{(1+\frac{n}{d})\frac{n}{d}}{2} \]

\[=\frac{n}{2}\sum_{d|n}μ(d)+μ(d)·\frac{n}{d} \]

\[=\frac{1}{2}(nφ(n)+ε(n)) \]

(4)

\[d=gcd(i,j) \]

\[φ(ij)=\frac{φ(i)φ(j)d}{φ(d)} \]

\[∀n=p^a,m=p^b,a<=b,若φ(nm)=\frac{φ(n)φ(m)gcd(n,m)}{φ(gcd(n,m))},则上式成立 \]

\[n'=n*px \]

\[φ(n'm)=\frac{φ(nm)φ(px)gcd(nm,px)}{φ(gcd(nm,px))}=\frac{φ(nm)φ(px)}{φ(1)}=φ(nm)φ(px) \]

\[φ(p^x)=p^x-\lfloor\frac{p^x}{p}\rfloor=p^x-p^{x-1} \]

\[右边=\frac{φ(p^a)φ(p^b)gcd(p^a,p^b)}{φ(gcd(p^a,p^b))} \]

\[\frac{(p^a-p^{a-1})(p^b-p^{b-1})p^a}{(p^a-p^{a-1})} \]

\[p^{a+b}-p^{a+b-1} \]

\[φ(p^{a+b})=左边 \]

4.数论分块

\[\sum_{i=2}^{n}\lfloor\frac{n}{i}\rfloor \]

\[l=2,r=n/(n/l) \]

\[l=r+1 \]

\[ans=\sum(r-l+1)·(n/l) \]

5.积性函数

(1)

\[∀x∈N,y∈N,gcd(x,y)=1,f(1)=1,都有f(xy)=f(x)f(y),则f(x)是积性函数 \]

\[∀x∈N,y∈N,f(1)=1,都有f(xy)=f(x)f(y),则f(x)是完全积性函数 \]

(2)

\[ε(n)=[n=1] \]

\[id(n)=n \]

\[σ(n)=\sum_{d|n}d \]

\[I(n)=1 \]

\[φ(n)=\sum_{i=1}^{n}[gcd(i,n)=1] \]

\[μ(n)= \begin{cases} (-1)^k,n=p1p2...pk\\ 0,n=p^2q\\ 1,n=1 \end{cases} \]

6.狄利克雷卷积

(1)

\[(f*g)(n)=\sum_{d|n}f(d)g(\frac{n}{d}) \]

(2)

\[(f*g=g*f) \]

\[(f*g)*h=f*(g*h) \]

\[f*(g+h)=f*g+f*h \]

\[f*ε=f \]

7.莫比乌斯反演

(1)

\[\sum_{d|n}μ(d)= \begin{cases} 1,n=1\\ 0,n≠1 \end{cases} =ε(n),μ*I=ε \]

\[n=Π_{i=1}^kpi^{ci},n'=Π_{i=1}^kpi \]

\[∴\sum_{d|n}μ(d)=\sum_{d|n'}μ(d)=\sum_{i=0}^kC_{i}^k·(-1)^k=(1+(-1))^k=0^k \]

\[k=0<=>n=0,k≠0<=>n≠0 \]

\[\sum_{d|n}μ(d)=ε(n) \]

(2)

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

\[g(n)=\sum_{d|n}μ(d)f(\frac{n}{d}) \]

\[f=I*g \]

\[μ*f=μ*I*g \]

\[μ*f=ε*g=g \]

(3)

\[\sum_{i=1}^n\sum_{j=1}^mai·bj=\sum_{i=1}^nai\sum_{j=1}^mbj \]

\[\sum_{i=1}^nai\sum_{j=1}^mbj=\sum_{j=1}^mbj\sum_{i=1}^nai \]

\[\sum_{i=1}^na_i\sum_{d|i}b_d=\sum_{d=1}^nb_d\sum_{i=1}^{\lfloor\frac{n}{d}\rfloor}a_{id} \]

(4)

\[\sum_{i=1}^n\sum_{j=1}^m[gcd(i,j)=k] \]

\[\sum_{i=1}^{\lfloor\frac{n}{k}\rfloor}\sum_{j=1}^{\lfloor\frac{m}{k}\rfloor}[gcd(i,j)=1] \]

\[\sum_{i=1}^{\lfloor\frac{n}{k}\rfloor}\sum_{j=1}^{\lfloor\frac{m}{k}\rfloor}ε(gcd(i,j)) \]

\[\sum_{i=1}^{\lfloor\frac{n}{k}\rfloor}\sum_{j=1}^{\lfloor\frac{m}{k}\rfloor}\sum_{d|gcd(i,j)}μ(d) \]

\[\sum_{d=1}μ(d)\sum_{i=1}^{\lfloor\frac{n}{k}\rfloor}[d\mid i]\sum_{j=1}^{\lfloor\frac{m}{k}\rfloor}[d\mid j] \]

\[\sum_{d=1}μ(d)\lfloor\frac{n}{kd}\rfloor\lfloor\frac{m}{kd}\rfloor \]

8.杜教筛

(1)

\[\sum_{i=1}^nf(i) \]

\[S(n)=\sum_{i=1}^nf(i) \]

\[h=g*f \]

\[\sum_{i=1}^nh(i)=\sum_{i=1}^n\sum_{d|i}g(d)f(\frac{n}{d}) \]

\[\sum_{i=1}^nh(i)=\sum_{d=1}^ng(d)\sum_{i=1}^{\lfloor\frac{n}{d}\rfloor}f(i) \]

\[\sum_{i=1}^nh(i)=\sum_{d=1}^ng(d)S(\lfloor\frac{n}{d}\rfloor) \]

\[\sum_{i=1}^nh(i)=g(1)S(n)+\sum_{d=2}^ng(d)S(\lfloor\frac{n}{d}\rfloor) \]

\[g(1)S(n)=\sum_{i=1}^nh(i)-\sum_{d=2}^ng(d)S(\lfloor\frac{n}{d}\rfloor) \]

(2)

\[\sum_{i=1}^nμ(i) \]

\[μ*I=ε \]

\[S(n)=\sum_{i=1}^nε(i)-\sum_{d=2}^nS(\lfloor\frac{n}{d}\rfloor) \]

\[S(n)=1-\sum_{d=2}^nS(\lfloor\frac{n}{d}\rfloor) \]

(3)

\[\sum_{i=1}^nφ(i) \]

\[id=φ*I \]

\[S(n)=\sum_{i=1}^nid(i)-\sum_{d=2}^nS(\lfloor\frac{n}{d}\rfloor) \]

\[S(n)=\sum_{i=1}^ni-\sum_{d=2}^nS(\lfloor\frac{n}{d}\rfloor) \]

9.CRT

\[\begin{cases} x≡a1(mod\ n1)\\ x≡a2(mod\ n2)\\ ...\\ x≡ak(mod\ nk)\\ \end{cases} \]

\[N=Π_{i=1}^kni \]

\[mi=\frac{N}{ni} \]

\[mixi≡1(mod\ ni) \]

\[ci=mimi^{-1} \]

\[x=\sum_{i=1}^kaici(mod\ N) \]

10.Lucas

\[C_n^m=C_{n\ mod \ p}^{m\ mod \ p}·C_{n/p}^{m/p} \]

11.Burnside&Pólya

\[A,B:有限集合,X:A到B的所有映射 \]

\[G:置换群,X/G:所有作用在X上的置换群的等价类的集合 \]

\[|X/G|=\frac{1}{|G|}∑_{i=1}^{|G|}|f(G_i)| \]

\[f(G_i)即为经过一轮置换后仍等价于它本身的点集合 \]

\[|X/G|=\frac{1}{|G|}∑_{i=1}^{|G|}B^{c(G_i)} \]

\[c(G_i)即为将C_i拆成不交的循环置换的个数 \]

12.Min_25

\[F_k(n)=\sum_{i>=k,p_i^2<=n}\sum_{c>=1,p_i^c<=n}f(p_i^c)([c>1]+F_{i+1}(\lfloor\frac{n}{p_i^c}\rfloor))+\sum_{i>=k}f(p_i) \]

\[F_k(n)=\sum_{i>=k,p_i^2<=n}\sum_{c>=1,p_i^{c+1}<=n}(f(p_i^c)F_{i+1}(\lfloor\frac{n}{p_i^c}\rfloor)+f(p_i^{c+1}))+F_{prime}(n)-F_{prime}(p_{k-1}) \]

\[G_k(n)=G_{k-1}(n)-g(\lfloor\frac{n}{p_k}\rfloor)(G_{k-1}(\lfloor\frac{n}{p_k}\rfloor)-G_{k-1}(p_{k-1})) \]

posted @ 2021-01-30 16:28  冰雾  阅读(102)  评论(0编辑  收藏  举报