欧拉函数
SYaoJun
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
NowCoder的密码
牛客网题目链接 题意 全排列给出的数据,然后从这些全排列中选出素数输出。 注意 不存在素数时要输出NONE 每个测试数据间需要增加一个空行 #include <iostream> #include <string> #include <vector> #include <cctype> #include <cstdio> #inclu...原创 2019-10-25 17:14:55 · 382 阅读 · 0 评论 -
874. 筛法求欧拉函数
AcWing题目链接 #include <iostream> using namespace std; typedef long long LL; const int N = 1e6+5; int primes[N]; bool st[N]; int phi[N]; int k = 0; LL get_eulers(int n){ phi[1] = 1; for(int...原创 2019-10-24 10:00:47 · 173 阅读 · 0 评论 -
P3383 【模板】线性筛素数
https://www.luogu.org/problemnew/show/P3383 相信大家都会埃式筛选,这里就不赘述了,先放个板子,以后容易找。 //欧拉素数筛选 #include #include #define N 10000005 #define LL long long LL prime[N]; int p[N]; void primeTable(int n){原创 2018-01-31 04:14:09 · 390 阅读 · 0 评论 -
868. 筛质数
AcWing题目链接 埃氏筛法 时间复杂度O(nloglogn)O(nloglogn)O(nloglogn) #include <iostream> using namespace std; const int N = 1e6+5; int primes[N]; bool st[N]; int k = 0; void get_primes(int n){ for(int i =...原创 2019-10-23 23:50:46 · 225 阅读 · 0 评论 -
873. 欧拉函数
AcWing题目链接 欧拉函数 ϕ(n)\phi(n)ϕ(n)表示1∼n1\sim n1∼n中与nnn互质的个数 n=p1α1p2α2…pkαkn = p_1^{\alpha_1}p_2^{\alpha_2} \dots p_k^{\alpha_k}n=p1α1p2α2…pkαk ϕ(n)=n(1−1p1)(1−1p2)…(1−1pk)\phi(n)= n(1-\frac{1}{p_1...原创 2019-10-23 22:55:06 · 186 阅读 · 0 评论
分享