poj 1811 Prim test】的更多相关文章

基本上一个裸的Miller_Rabin大素数判定和一个裸的Pollard_rho素数分解算法,当模板用吧! #include<cstdio> #include<algorithm> #include<stdlib.h> #define LL long long using namespace std; ; int tol; LL factor[]; LL mult_mod(LL a,LL b,LL c)//计算a*b%c; { LL ret=; a%=c; b%=c;…
素数判定Miller_Rabin算法详解: http://blog.csdn.net/maxichu/article/details/45458569 大数因数分解Pollard_rho算法详解: http://blog.csdn.net/maxichu/article/details/45459533 然后是参考了kuangbin的模板: http://www.cnblogs.com/kuangbin/archive/2012/08/19/2646396.html 模板如下: //快速乘 (a…
题目链接 Description Given a big integer number, you are required to find out whether it's a prime number. Input The first line contains the number of test cases T (1 <= T <= 20 ), then the following T lines each contains an integer number N (2 <= N…
POJ 1811 Prime Test Time Limit: 6000MS   Memory Limit: 65536K Total Submissions: 32534   Accepted: 8557 Case Time Limit: 4000MS Description Given a big integer number, you are required to find out whether it's a prime number. Input The first line con…
http://poj.org/problem?id=2421 这个题和poj1258是一样的,只要在1258的基础上那么几行代码,就可以A,水. 题意:还是n连通问题,和1258不同的就是这个还有几条路在之前就已经连通了的,所以不需要再去连. #include <stdio.h> #include <string.h> #define inf 100009 ]; ][],dis[],ans,n; int prim() { ;i<=n;i++) dis[i]=inf;dis[]…
题目链接:http://poj.org/problem?id=1251 字符用%s好了,方便一点. #include <stdio.h> #include <string.h> #define INF 0x3f3f3f3f ][]; ]; ]; int n; int Prim() { memset(vis,false,sizeof(vis)); ; i<=n; i++) dis[i] = INF; ; dis[] = ; ; i<=n; i++) { ; ; j<…
Building a Space Station Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 4400 Accepted: 2255 Description You are a member of the space station engineering team, and are assigned a task in the construction process of the station. You are ex…
Prime Test Time Limit: 6000MS   Memory Limit: 65536K Total Submissions: 29046   Accepted: 7342 Case Time Limit: 4000MS Description Given a big integer number, you are required to find out whether it's a prime number. Input The first line contains the…
模板 #include<stdio.h> #include<string.h> #include<stdlib.h> #include<time.h> #include<iostream> #include<string.h> #include<math.h> #include<algorithm> using namespace std; //*********************************…
/* 题目:给出一个数 如果是prime 输出prime 否则输出他的最小质因子 Miller Rabin +Poller Rho 大素数判定+大数找质因子 后面这个算法嘛 基于Birthday Paradox 简单点说就是 在 1到100 内去一个数 ai ai==42的概率很小 但是如果取两个数 ai bi ai-bi==42 的概率就会变大 应用到找素因子上 就不用像试除法那样一个一个的试 但是如果枚举ai bi 显然也很slow 那么有一个非常好使(奇怪)的函数 f(x)=x*x+c 这…