
数论
数论
SWUST_Vector
心怀希望的人最强大!!!
展开
-
莫比乌斯反演+整除分块
莫比乌斯反演:若:F(n)=∑d|n {f(d)}则:f(n)=∑d|n {μ(d)*F(⌊n/d⌋)}或者是:若:F(n)=∑n|d {f(d)}则:f(n)=∑n|d {μ(d/n)F(d)}两种情况。题目:洛谷P3455莫比乌斯反演模版题:求满足 1≤x≤a,1≤y≤b且 gcd(x,y)=k 的二元组 (x,y) 的数量。gcd(x,y)==k 推出 gcd(...原创 2020-04-07 19:22:07 · 211 阅读 · 0 评论 -
欧拉函数
欧拉函数φ(x): 表示小于等于x的与x互为质因子的个数;φ(x)=x(1-1/p(1))(1-1/p(2))(1-1/p(3))(1-1/p(4))……(1-1/p(n)) 其中p(1),p(2)…p(n)为x的所有质数因数;x是正整数; φ(1)=1(唯一和1互质的数,且小于等于1)。注意:每种质数因数只有一个。#include <iostream>#include <...原创 2020-04-03 18:57:29 · 305 阅读 · 0 评论 -
gcd(最大公约数)
#include <iostream>#include <algorithm>#include <cstdio>using namespace std;int gcd(int a, int b){ return !b? a:gcd(b,a%b);}int main(){ int a,b; while(scanf("%d%d...原创 2020-03-17 10:37:12 · 221 阅读 · 0 评论 -
线性筛素数
void deal(){ int N=1e5+55,cnt=0; bool p[N]; int num[N]; for(int i=0;i<N;++i) p[i]=false; for(int i=2;i<N;++i){ if(!p[i]) num[cnt++]=i; for(int j=0;j&...原创 2020-03-17 10:29:18 · 107 阅读 · 0 评论