数论
muyu__
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
求组合数(扩展欧几里得+费马小定理)
扩展欧几里得: #include<iostream> #include<cstdio> #include<cstring> using namespace std; const int mod=1e9+7; void exgcd(long long a,long long b,long long &x,long long &y) { if...原创 2019-02-27 20:22:44 · 362 阅读 · 0 评论 -
分解质因数
给你一个数n(2&amp;lt;=n&amp;lt;=1000000),求n的质因数。 欧拉筛法(O(n)):素数的倍数一定为合数,我们每找到一个数,就将其素数倍数的数标记为合数。 #include&amp;lt;iostream&amp;gt; #include&amp;lt;cstdio&amp;gt; #include&amp;lt;cstring&amp;gt; using原创 2018-11-09 21:28:37 · 805 阅读 · 0 评论 -
判断素数
问题:给你一个数,问你这个数是否为素数? 定理:如果一个数不能被其平方根以内的(素)数整除,其一定为素数。 证明:对于一个合数n,其一定可以达成n=a*b的形式(a和b为n的约数),其中一个约数大于等于n\sqrt{n}n ,另一个小于等于n\sqrt{n}n,所以如果n不能被n\sqrt{n}n以内的(素)数整除,其必为素数。 普通版: #include&lt;iostream&gt;...原创 2018-12-14 21:12:27 · 402 阅读 · 0 评论 -
【模板】超级幂(欧拉降幂)
题意:求a ^ a ^ a ^ a…(b次)对mod取模 #include<iostream> #include<cstdio> #include<cstring> using namespace std; long long phi(long long x) { long long res=x; for(long long i=2;i*i&l...原创 2019-09-02 21:06:27 · 1928 阅读 · 0 评论 -
【模板】中国剩余定理解同余方程(附_int128)
//问题:求解同余方程组 // x ≡ a1 (mod b1) // x ≡ a2 (mod b2) // x ≡ a3 (mod b3) // ······ // x ≡ an (mod bn) //其中b1,b2,b3,······ bn 为不一定两两互质的整数,求x的最小非负整数 //模板 #include<bits/stdc++.h> #define up(i, x, y)...原创 2019-09-09 18:46:53 · 498 阅读 · 0 评论
分享