2018年12月8日

莫比乌斯函数

摘要: const int maxn=1000000+5; bool check[maxn]; int prime[maxn],mu[maxn]; void Moblus(int n){ memset(check,0,sizeof(check)); mu[1]=1; int tot=0; for(int i=2;in) break; check[i... 阅读全文

posted @ 2018-12-08 19:15 欣崽 阅读(227) 评论(0) 推荐(0)

求a^b的约数对mod取模

摘要: const int maxn=30000+5; int prime[maxn]; void marktable(int n){ memset(prime,0,sizeof(prime)); for(int i=2;i T fast_mod(T a,T b,T1 Mod){ a%=mod; if(b==0) return 1; T ans=1,base=a... 阅读全文

posted @ 2018-12-08 19:11 欣崽 阅读(263) 评论(0) 推荐(0)

线性筛

摘要: 同时得到欧拉函数和素数表 阅读全文

posted @ 2018-12-08 18:36 欣崽 阅读(194) 评论(0) 推荐(0)

素数筛

摘要: 1 O(n*logn) 同时生成素数表 2 O(n)同时生成素数表 3 只生成素数筛 阅读全文

posted @ 2018-12-08 18:26 欣崽 阅读(186) 评论(0) 推荐(0)

线性求逆元

摘要: const int maxn=3000000; ll inv[maxn+5]; void marktable_inv(int p){ inv[0]=inv[1]=1; for(int i=2;i<maxn;i++) inv[i]=(p-p/i)*inv[p%i]%p; } 阅读全文

posted @ 2018-12-08 18:12 欣崽 阅读(141) 评论(0) 推荐(0)

求逆元

摘要: 1 利用扩展欧几里得求解 2 利用欧拉函数 阅读全文

posted @ 2018-12-08 17:59 欣崽 阅读(187) 评论(0) 推荐(0)

扩展BSGS求解离散对数问题

摘要: 扩展BSGS用于求解axΞb mod(n) 同余方程中gcd(a,n)≠1的情况 基本思路,将原方程转化为a与n互质的情况后再套用普通的BSGS求解即可 const int maxint=((1<<30)-1)*2+1; struct Hashmap{ static const int Ha=999 阅读全文

posted @ 2018-12-08 12:45 欣崽 阅读(202) 评论(0) 推荐(0)

自定义结构体 Map

摘要: struct Hashmap{ static const int Ha=999917,maxe=46340; int E,lnk[Ha],son[maxe+5],nxt[maxe+5],w[maxe+5]; int top,stk[maxe+5]; void clear() {E=0;while(top) lnk[stk[top--]]=0;} void ... 阅读全文

posted @ 2018-12-08 12:43 欣崽 阅读(396) 评论(0) 推荐(0)

BSGS求解离散对数问题

摘要: 离散对数问题是求解axΞb mod(n) 同余方程 以下模板使用于gcd(a,n)=1的情况 阅读全文

posted @ 2018-12-08 12:12 欣崽 阅读(603) 评论(0) 推荐(0)

导航