主要是为了试一下MILLER-RABIN的方法#include #include #include #include #define LL __int64using namespace std;const LL TIME=1000;LL random(LL n){ return (LL)((doub...
分类:
其他好文 时间:
2014-09-06 09:45:02
阅读次数:
176
Prime TestTime Limit:6000MSMemory Limit:65536KTotal Submissions:29046Accepted:7342Case Time Limit:4000MSDescriptionGiven a big integer number, you are...
分类:
其他好文 时间:
2014-09-03 00:03:15
阅读次数:
732
#include
#include
#include
#include
using namespace std;
typedef __int64 LL;
const int Times = 20;
LL factor[100], l;
LL gcd(LL a, LL b)
{
return b ? gcd(b, a%b):a;
}
LL add_mod(LL a, LL b, LL n)...
分类:
其他好文 时间:
2014-08-30 20:28:20
阅读次数:
285
#include
#include
#include
#include
using namespace std;
typedef __int64 LL;
const int Times = 20;
LL factor[100], l;
LL gcd(LL a, LL b)
{
return b ? gcd(b, a%b):a;
}
LL add_mod(LL a, LL b, LL n)...
分类:
其他好文 时间:
2014-08-19 20:57:05
阅读次数:
254
随机算法,Miller Rabin和Pollard Rho的应用...
分类:
其他好文 时间:
2014-08-09 18:46:48
阅读次数:
176
题目描述 Give you a lot of positive integers, just to find out how many prime numbers there are.. In each case, there is an integer N representing the num...
分类:
其他好文 时间:
2014-07-30 23:35:35
阅读次数:
300
ll random(ll n){ return (ll)((double)rand()/RAND_MAX*n + 0.5);}ll pow_mod(ll a,ll p,ll n){ if(p == 0) return 1; ll ans = pow_mod(a,p/2...
分类:
其他好文 时间:
2014-07-01 12:29:43
阅读次数:
218
题目就是给出一组数,让我们测试其中有多少个是素数。
求素数有测试sqrt(n)个数的方法,有筛子方法,不过对于本题这样的题目来说就都不是高效的。
本题使用Miller Rabin素数测试法,效率奇高,对于不是极其大的整数测试都几乎是常数时间。令人神往的算法啊。
网上有个程序,好像是什么吉林的模板程序,不过我一直没看懂他是什么思路写的,是个AC的程序,不过却是错误的,呵呵,因为程序一直把9当做...
分类:
其他好文 时间:
2014-06-15 18:48:07
阅读次数:
194