摘要: 很明显可以转化为反素数的题目。由于有n种不同的方式,所以,数的约数可以为2*n或者2*n-1#include #include #include #define LL __int64using namespace std;LL p[16]={2,3,5,7,11,13,17,19,23,29,31,... 阅读全文
posted @ 2014-09-06 20:08 chenjunjie1994 阅读(147) 评论(0) 推荐(0) 编辑
摘要: 了解反素数的定义:反素数是指[1,n]内,比n小的数的约数个数都比n的约数个数要少。注意n其实是最后一个。而在区间内,[a,b]是明显无法满足条件的。注意了最大才5000.所以,不妨使用枚举。#include #include #include using namespace std;const i... 阅读全文
posted @ 2014-09-06 16:30 chenjunjie1994 阅读(193) 评论(0) 推荐(0) 编辑
摘要: 注意题目中的一句话:If a number m has bigger evaluating value than all the numbers smaller than it。。。这让我重新想过反素数的定义,应该 是比n小的数的约数的个数都 小于 n。所以,应该取最小的一个值#include #i... 阅读全文
posted @ 2014-09-06 16:15 chenjunjie1994 阅读(230) 评论(0) 推荐(0) 编辑
摘要: 在讲解反素数之前,我们先来看反素数的概念。反素数的定义:对于任何正整数,其约数个数记为,例如,如果某个正整数满足:对任意的正整 数,都有,那么称为反素数。从反素数的定义中可以看出两个性质:(1)一个反素数的所有质因子必然是从2开始的连续若干个质数,因为反素数是保证约数个数为的这个数尽量小(2)同样的... 阅读全文
posted @ 2014-09-06 15:45 chenjunjie1994 阅读(210) 评论(0) 推荐(0) 编辑
摘要: 可以先找出回文数,再用素数测试来判是否为素数即可。打回文数时,因为左右对称,可以只枚举后半部,然后通过逆转得到前半部分。#include #include #include #include #include using namespace std;const int Max=200000;int ... 阅读全文
posted @ 2014-09-06 11:30 chenjunjie1994 阅读(197) 评论(0) 推荐(0) 编辑
摘要: 这题用MILLER测试应该是不可避免的。#include #include #include #include #define LL __int64using namespace std;LL random(LL n){ return (LL)((double)rand()/RAND_MAX*n+0... 阅读全文
posted @ 2014-09-06 09:43 chenjunjie1994 阅读(143) 评论(0) 推荐(0) 编辑
摘要: 主要是为了试一下MILLER-RABIN的方法#include #include #include #include #define LL __int64using namespace std;const LL TIME=1000;LL random(LL n){ return (LL)((doub... 阅读全文
posted @ 2014-09-06 09:23 chenjunjie1994 阅读(177) 评论(0) 推荐(0) 编辑