码迷,mamicode.com
首页 >  
搜索关键字:bear and prime numbe    ( 2904个结果
poj 3126 Prime Path (bfs)
题意:给定两个素数四位m,n(不含前导0),求从m转化到n至少需要几次 转化规则:每次转化y与x只有一位数字不同,且y为素数 若能从m转化为n,输出转化的最小次数,否则输出Impossible 分析:因为要用到四位数的素数,首先用筛选法求出素数.然后分别只变换个位,十位,百位,千位四种情况来bfs 注意:最高位数字不能为0,对于四位素数肯定都是奇数,这样可以减少bfs次数...
分类:其他好文   时间:2014-07-28 16:24:53    阅读次数:186
poj 3126 Prime Path (bfs)
链接:poj 3126题意:给定两个素数四位m,n(不含前导0),求从m转化到n至少需要几次转化规则:每次转化y与x只有一位数字不同,且y为素数若能从m转化为n,输出转化的最小次数,否则输出Impossible分析:因为要用到四位数的素数,首先用筛选法求出素数.然后分别只变换个位,十位,百位,千位四...
分类:其他好文   时间:2014-07-27 23:13:39    阅读次数:244
Problem E CodeForces 237C
DescriptionYou've decided to carry out a survey in the theory of prime numbers. Let us remind you that a prime number is a positive integer that has e...
分类:其他好文   时间:2014-07-27 22:51:29    阅读次数:288
CodeForces 237C Primes on Interval
DescriptionYou've decided to carry out a survey in the theory of prime numbers. Let us remind you that a prime number is a positive integer that has e...
分类:其他好文   时间:2014-07-27 22:31:39    阅读次数:809
POJ 3126 Prime Path
很水的一个BFS,不过还是有坑点的,就是数都是大于1000的,我在千位时取过零,想了很久 不够细心啊!!! AC代码如下: #include #include #include #include #include #include #include #include #include #include typedef __int64 LL; #define maxn 0x7f...
分类:其他好文   时间:2014-07-27 11:28:12    阅读次数:203
Java杂谈三之判断素数以及穷举素数
首先确认下什么是素数,又称质数 百度的定义解答: 质数(prime number)又称素数,有无限个。一个大于1的自然数,如果除了1和它本身 外,不能被其他自然数整除(除0以外)的数称之为素数(质数) 明确了素数的定义后,下面用java来判断素数以及穷举2-999以内的素数,还是一样,主 要看的是对一个数进行判断或者对一组数进行判断的思想,至于怎样判断的,百度的定义已经给...
分类:编程语言   时间:2014-07-26 15:11:27    阅读次数:238
CodeForces 432C Prime Swaps
DescriptionYou have an arraya[1],?a[2],?...,?a[n], containing distinct integers from1ton. Your task is to sort this array in increasing order with the...
分类:其他好文   时间:2014-07-26 14:34:41    阅读次数:263
poj 2034 Anti-prime Sequences(dfs)
//相邻的 2.3......d 之和都要不为素数 # include # include using namespace std; int num[1010],vis[1010]; int n,m,d,cot; int flag[10010]; void init()//素数打表 { int i,j; for(i=2;i<10010;i++) { if(!flag[i]) f...
分类:其他好文   时间:2014-07-24 11:32:42    阅读次数:234
poj 2689 Prime Distance(大区间筛素数)
http://poj.org/problem?id=2689 题意:给出一个大区间[L,U],分别求出该区间内连续的相差最小和相差最大的素数对。 因为L2147483647,直接筛素数是不行的,数组就开不了。但是可以根据素数筛的原理。我们先筛出sqrt(2147483647)以内的素数,然后拿这些素数去筛[L,U]之间的素数,即两次素数筛。但是L,U还是很大,但U-L #includ...
分类:其他好文   时间:2014-07-24 10:28:16    阅读次数:210
poj 3292 Semi-prime H-numbers
题目链接:http://poj.org/problem?id=3292 题目大意:就是给你一个模4余1的数H-number,如果一个H-number是H-primes 当且仅当它的因子只有1和它本身(除1外)。一个H-number是H-semi-prime当且仅当它只由两个H-primes的乘积表示。H-number剩下其他的数均为H-composite。给你一个数h,问1到h有多少个H-sem...
分类:其他好文   时间:2014-07-23 22:38:17    阅读次数:302
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!