pseudoprime专题

POJ 3641 Pseudoprime numbers 伪素数测试

题意:判断一个数是否是基于a的伪素数。只有当p是合数且a^p = a ( mod p ) 时,才输出yes。 题解:Miller_Rabin素数测试。 #include<cstdio>#include<ctime>#include<cstdlib>using namespace std;#define lint __int64lint modular_exponent ( lint

POJ 3641 Pseudoprime numbers 快速幂+判断素数 快速幂模板

题目链接 Description Fermat’s theorem states that for any prime number p and for any integer a > 1, ap = a (mod p). That is, if we raise a to the pth power and divide by p, the remainder is a. Some (but