For each test case, if N is a prime number, output a line containing the word "Prime", otherwise, output a line containing the smallest prime factor of N. Sample Input 2 5 10 Sample Output Prime 2 Source POJ Monthly C++: #include<algorithm> #include<iostream> #include<cstdio> #include...
题目链接:http://poj.org/problem?id=1811 题意: 判断一个数 n (2 <= n < 2^54)是否为质数, 是的话输出 "Prime", 否则输出其第一个质因子. 思路: 大数质因子分解, 直接用 pollard_rho (详情参见:http://blog.csdn.net/maxichu/article/details/45459533) 模板即可. 代码: View Code...
题意:是素数就输出Prime,不是就输出最小因子. #include <cstdio> #include #include <algorithm> #include<set> using namespace std; typedef long long llt; int const Repeat = 10; set<llt>sss; //利用二进制计算a*b%mod llt multiMod(llt a, llt b, llt mod){ llt ret = 0LL; a %= mod...
模板题Pollard_Rho大数分解 A - Prime Test POJ - 1811 题意:是素数就输出Prime,不是就输出最小因子. AI检测代码解析 #include <cstdio>#include#include<algorithm>#include<set>usingnamespacestd; typedeflonglongllt;intconstRepeat =10;set<llt>sss;//利用二进制计算a*b%modllt multiMod(llt a, llt b...