上一页 1 ··· 22 23 24 25 26 27 28 29 30 ··· 38 下一页
摘要: 使用递推求欧拉函数,因为FN就是欧拉函数的累加和。#include #include #include #include using namespace std;const int Max=1000010;int phi[Max];int main(){ for(int i=1;i<Max;i++)... 阅读全文
posted @ 2014-09-10 11:33 chenjunjie1994 阅读(146) 评论(0) 推荐(0) 编辑
摘要: 想了很久,只想到枚举的方法,估计会超时吧。原来有这样一条性质:p为素数,则p有phi(p-1)个原根Orz...#include #include #include #include using namespace std;int main(){ int n; while(scanf("%d",&n... 阅读全文
posted @ 2014-09-10 10:33 chenjunjie1994 阅读(167) 评论(0) 推荐(0) 编辑
摘要: 裸 的求欧拉函数#include #include #include #include #include using namespace std;int main(){ int n; while(scanf("%d",&n),n){ int res=n; int L=(int)sqrt(n*1.... 阅读全文
posted @ 2014-09-09 21:50 chenjunjie1994 阅读(126) 评论(0) 推荐(0) 编辑
摘要: 使用Pollard_rho算法分解lcm/gcd的质因数,原因不说也明白了。然后排序,把相同的质因子合并,因为如果相同的质因子分落在两个因数,会使ab的GCD值改变。然后,枚举各种组合,呃。。。。这个实在想不到好方法,只好枚举了,真想不明白,那么两位数时间的是怎么样做到的。#include #inc... 阅读全文
posted @ 2014-09-08 20:24 chenjunjie1994 阅读(246) 评论(0) 推荐(0) 编辑
摘要: 使用Pollard_rho算法就可以过了#include #include #include #include #include #include #include #define LL __int64using namespace std;LL ans;const LL C=201;LL rand... 阅读全文
posted @ 2014-09-08 20:20 chenjunjie1994 阅读(210) 评论(0) 推荐(0) 编辑
摘要: 因为规模小,使用试除法即可#include #include #include #include using namespace std;const int Maxn=100;int prime[Maxn];int main(){ int n,m; while(scanf("%d",&n)!=EOF... 阅读全文
posted @ 2014-09-07 21:06 chenjunjie1994 阅读(198) 评论(0) 推荐(0) 编辑
摘要: 很明显可以转化为反素数的题目。由于有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 阅读(146) 评论(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 阅读(191) 评论(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 阅读(228) 评论(0) 推荐(0) 编辑
摘要: 在讲解反素数之前,我们先来看反素数的概念。反素数的定义:对于任何正整数,其约数个数记为,例如,如果某个正整数满足:对任意的正整 数,都有,那么称为反素数。从反素数的定义中可以看出两个性质:(1)一个反素数的所有质因子必然是从2开始的连续若干个质数,因为反素数是保证约数个数为的这个数尽量小(2)同样的... 阅读全文
posted @ 2014-09-06 15:45 chenjunjie1994 阅读(209) 评论(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 阅读(176) 评论(0) 推荐(0) 编辑
摘要: 快速幂模+佩尔方程#include #include #include #include const int Mod=8191;struct Matrax { int m[3][3];};Matrax a,per;void slove(int d,int &x1,int &y1){ y1=1; wh... 阅读全文
posted @ 2014-09-04 21:04 chenjunjie1994 阅读(121) 评论(0) 推荐(0) 编辑
摘要: 作弊了--!该题可以通过因式分解得到一个佩尔方程。。。。要不是学着这章,估计想不到。。得到x1,y1后,就直接代入递推式递推了x[n]=x[n-1]*x[1]+d*y[n-1]*y[1]y[n]=x[n-1]*y[1]+y[n-1]*x[1]#include #include #include #i... 阅读全文
posted @ 2014-09-04 20:33 chenjunjie1994 阅读(175) 评论(0) 推荐(0) 编辑
上一页 1 ··· 22 23 24 25 26 27 28 29 30 ··· 38 下一页