数论算法——质数筛法
RomanticChopin
这个作者很懒,什么都没留下…
展开
-
素数表的获取,埃氏筛法 介绍(复杂度 : O(n*loglogn) )
该算法时间复杂度为: O(n*loglogn)当 n = 1e6 时 , 复杂度约为 7.7 * 10^5 ,优于O( n )//素数线性筛法,复杂度:O(nloglogn) //求100以内素数 #include<iostream>#include<cstring>#include<string>using namespace st...原创 2019-01-12 16:05:07 · 1368 阅读 · 3 评论 -
Codeforces 1076B Divisor Subtraction
线性筛法,数学问题,找规律。 You are given an integer number nn. The following algorithm is applied to it:if n=0n=0, then end algorithm; find the smallest prime divisor dd of nn; subtract dd from nn and go...原创 2019-01-12 16:04:43 · 214 阅读 · 0 评论 -
2019 蓝桥杯省赛 B 组模拟赛(一) 程序设计:找质数 ( 埃氏筛法 筛选素数)
一天蒜头君猜想,是不是所有的偶数(除了 22),都可以用两个质数相加得到呢?于是聪明的蒜头君就找你来验证了。输入格式第一行输入一个整数 tt 表示测试组数。接下来 tt 行,每行一个整数 nn。输出格式输出两个整数,因为答案可能有多个,所有要求输出的这两个整数是所有答案中字典序最小的。数据范围对于 30\%30% 的数据 1 \le t \le 10^31≤t≤103。...原创 2019-02-01 16:56:08 · 891 阅读 · 1 评论