码迷,mamicode.com
首页 >  
搜索关键字:筛法    ( 586个结果
POJ 2689 Prime Distance(素数区间筛法--经典题)
大致题意:给定[L,R]区间,找出区间内的每个素数 数据范围 : 1 R-L 1,000,000. R的数值太大,所以不能直接筛[0,R]的,要空间和时间优化,用到区间筛法,另外注意不能用int,因为R和L都是满int的,中间有很多细节处理会爆int的,还要注意1不是素数,所以在区间筛中要特判一下,是个易错的地方 //1160K 16MS C++ 1539B #include #in...
分类:其他好文   时间:2015-04-03 23:58:39    阅读次数:320
【BZOJ】【2005】【NOI2010】能量采集
欧拉函数 玛雅,我应该先看看JZP的论文的……贾志鹏《线性筛法与积性函数》例题一 这题的做法……仔细想下可以得到:$ans=2*\sum_{a=1}^n\sum_{b=1}^m gcd(a,b)-n*m$ 那么重点就在于算$\sum_{a=1}^n\sum_{b=1}^m gcd(a,b)$这...
分类:其他好文   时间:2015-04-03 18:54:56    阅读次数:201
hdu 4548 筛法求素数 打表
题目:http://acm.hdu.edu.cn/showproblem.php?pid=4548Problem Description 小明对数的研究比较热爱,一谈到数,脑子里就涌现出好多数的问题,今天,小明想考考你对素数的认识。 问题是这样的:一个十进制数,如果是素数,而且它的各位数字和也是.....
分类:其他好文   时间:2015-03-29 13:37:03    阅读次数:146
蓝桥杯 - 幸运数 (打表)
历届试题 幸运数   时间限制:1.0s   内存限制:256.0MB        问题描述 幸运数是波兰数学家乌拉姆命名的。它采用与生成素数类似的“筛法”生成 。 首先从1开始写出自然数1,2,3,4,5,6,.... 1 就是第一个幸运数。 我们从2这个数开始。把所有序号能被2整除的项删除,变为: 1 _ 3 _ 5 _ 7 _ ...
分类:其他好文   时间:2015-03-22 09:21:41    阅读次数:308
位处理的低级筛法
不得不说位操作是件很神奇的东西//低级筛法#include#include#include#include#includeusing namespace std;int _count(unsigned int a){ int sum=0; for(unsigned int x=a;x;x...
分类:其他好文   时间:2015-03-18 13:55:54    阅读次数:154
hdu 2161 Primes 筛法求素数 大水题
Problem Description Write a program to read in a list of integers and determine whether or not each number is prime. A number, n, is prime if its only divisors are 1 and n. For this problem, the numbers 1 and 2 are not considered primes. Input Each inp...
分类:其他好文   时间:2015-03-13 14:24:56    阅读次数:130
HDU ACM 1262 寻找素数对
1、素数筛法,打表; 2、从中间向两边寻找。 #include using namespace std; int main() { bool p[10001]; int m,i,j; memset(p,0,sizeof(p)); for(i=2;i<=10000;i++) //筛出素数,打表 if(!p[i]) for(j=i+i;j<=1...
分类:其他好文   时间:2015-03-10 17:25:50    阅读次数:156
Topcoder SRM 652 DIV1 250
题意:大概是求前n个数的最大公倍数。解题思路:筛法+质因子分解,敲玩就去睡觉了,没想到没优化被cha了。。。解题代码: 1 // BEGIN CUT HERE 2 /* 3 4 */ 5 // END CUT HERE 6 #line 7 "ThePermutationGame.cpp...
分类:其他好文   时间:2015-03-10 08:58:27    阅读次数:387
codeforces 385C Bear and Prime Numbers
题意:给你一个数列,和m个询问,求 数组种 l -r 中所有质数的的倍数的个数和。解题思路:变形筛法。注意细节解题代码: 1 // File Name: 385c.cpp 2 // Author: darkdream 3 // Created Time: 2015年03月07日 星期六 18时24分...
分类:其他好文   时间:2015-03-07 21:13:00    阅读次数:209
hdu 2682 Tree 最小生成树~~~~水题一枚,,用到了筛法求素数,我竟然在格式上面PE了两次!!
Problem Description There are N (2<=N<=600) cities,each has a value of happiness,we consider two cities A and B whose value of happiness are VA and VB,if VA is a prime number,or VB is a prime number or (VA+VB) is a prime number,then they can be connected.W...
分类:其他好文   时间:2015-02-25 09:10:52    阅读次数:288
586条   上一页 1 ... 47 48 49 50 51 ... 59 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!