数论--筛法
淼润淽涵
这个作者很懒,什么都没留下…
展开
-
HDU—2136 Largest prime factor(问你一个数的最大质因子的素数表中的位置)
Problem DescriptionEverybody knows any number can be combined by the prime number. Now, your task is telling me what position of the largest prime factor. The position of prime 2 is 1, prime 3 is 2...原创 2019-12-17 09:09:58 · 176 阅读 · 0 评论 -
埃氏筛法的具体应用
预处理每个数的所有质因数#include<cstdio>#include<vector>using namespace std;const int N=100000+5;vector<int>prime_factor[N];void init(){ for(int i=2;i<N;i++) { if(pri...原创 2019-12-03 10:55:13 · 148 阅读 · 0 评论 -
求素数(质数)的方法及时间复杂度的比较
素数,又叫质数,定义是除了1和它本身以外不再有其他的因数时间复杂度O(n)bool prime(int x){//判断x是不是质数,是返回true,不是返回false if(x<=1) return false; for(int i=2;i<x;i++) { if(x%i==0) return fal...原创 2019-12-03 10:55:24 · 5215 阅读 · 5 评论 -
洛谷-------P1217 [USACO1.5]回文质数 Prime Palindromes
题目描述因为151既是一个质数又是一个回文数(从左到右和从右到左是看一样的),所以 151 是回文质数。写一个程序来找出范围[a,b](5 <= a < b <= 100,000,000)( 一亿)间的所有回文质数;输入格式:第 1 行: 二个整数 a 和 b .输出格式:输出一个回文质数的列表,一行一个。输入输出样例...原创 2019-05-25 22:38:37 · 131 阅读 · 0 评论 -
POJ 3518 Prime Gap( 筛法)
Problem DescriptionThe sequence of n − 1 consecutive composite numbers (positive integers that are not prime and not equal to 1) lying between two successive prime numbers p and p + n is called a p...原创 2019-05-11 23:59:48 · 223 阅读 · 0 评论