码迷,mamicode.com
首页 >  
搜索关键字:筛法    ( 586个结果
区间素数筛法
给定整数a和b,请问区间[a,b)内有多少个素数?a 2 #include 3 #include 4 using namespace std; 5 typedef long long ll; 6 const int maxn = 1000005; 7 bool is_prime[maxn]; 8.....
分类:其他好文   时间:2015-05-19 22:28:23    阅读次数:203
AOJ - 0009 Prime Number (素数筛法) && AOJ - 0005 (求最大公约数和最小公倍数)
http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=34870求n内的素数个数。 1 /* *********************************************** 2 Author : zch ...
分类:其他好文   时间:2015-05-19 18:17:50    阅读次数:292
C#筛法求出范围内的所有质数
科普篇:筛法是一种简单检定素数的算法。据说是古希腊的埃拉托斯特尼(Eratosthenes,约公元前274~194年)发明的,又称埃拉托斯特尼筛法(sieve of Eratosthenes). 说实话,之前我在求质数的场合都是验证某一数是否为质数的,用定义求即可方便的得出结论,代码如下: 01: ...
分类:Windows程序   时间:2015-05-19 00:25:23    阅读次数:215
欢迎使用CSDN-markdown编辑器
Problem defineWe want to find all the primes between 2~N, then how to find all the primes efficiently?Sieve of EratosthenesSieve of Eratosthenes method, is very efficient, the algorithm is: Create a li...
分类:其他好文   时间:2015-05-15 17:39:24    阅读次数:129
LeetCode:Count Primes
题目描述: Description: Count the number of prime numbers less than a non-negative number, n click to show more hints. 思路:利用厄拉多塞筛法。具体操作:先将 2~n 的各个数放入表中,然后在2的上面画一个圆圈,然后划去2的其他倍数;第一个既未画圈又没有被划去的数是3,将它画圈,...
分类:其他好文   时间:2015-05-11 16:08:03    阅读次数:126
HDU ACM 5211 Mutiple
分析:筛法的思想,首先记录每个值的坐标,在使用筛法。 #include using namespace std; int a[10005]; int f[10005]; int main() { int i,n,j,mx,ans,tmp; ios::sync_with_stdio(false); while(cin>>n) { mx=-1; memset(f,-1,size...
分类:其他好文   时间:2015-05-11 14:49:13    阅读次数:145
Eratosthenes,筛法求素数
//筛法求区间[0,n]的所有素数,v为素数表 //v[i]==0,i为素数void f(int n) { int m=sqrt(n+0.5); memset(v,0,sizeof(v)); for (int i=2;i<=m;i++) if (!v[i]) for ...
分类:其他好文   时间:2015-05-10 11:19:57    阅读次数:115
利用OpenMP实现埃拉托斯特尼(Eratosthenes)素数筛法并行化
1.算法简介1.1筛法起源筛法是一种简单检定素数的算法。据说是古希腊的埃拉托斯特尼(Eratosthenes,约公元前274~194年)发明的,又称埃拉托斯特尼筛法(sieve of Eratosthenes)。...
分类:其他好文   时间:2015-05-09 15:06:16    阅读次数:434
埃氏筛法
埃氏筛法/*用“埃氏筛法”求2~1/*00以内的素数。2~100以内的数,先去掉2的倍数,再去掉3的倍数,再去掉4的倍数,……依此类推,最后剩下的就是素数。*/package week_1;public class Sushu { public static void main(String[] a...
分类:其他好文   时间:2015-05-07 20:19:47    阅读次数:609
xdu 1022(数论筛法)
1022: A simple math problem 2 时间限制: 1 Sec  内存限制: 128 MB 提交: 73  解决: 13 [提交][状态][讨论版] 题目描述 高斯函数: [x]表示,小于等于x的最大整数,即向下取整。 如 [2.5]=2,[1.2]=1等。 定义函数f(n)=[n/1]+[n/2]+[n/3]+...+[n/n] . sum(a,b)=f(a...
分类:其他好文   时间:2015-05-07 06:30:49    阅读次数:228
586条   上一页 1 ... 44 45 46 47 48 ... 59 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!