poj1811

maksyuki 发表于 oj 分类,标签: ,
0

Prime Test

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 < 254).

Output

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

 

题目类型:Miller_Rabin测试和Pollard_Rho大整数分解

算法分析:先判断n是否是素数,如果是则直接输出”Prime”,反之则分解n大整数,生成n所有的素因子,然后找到最小的那一个即可,注意srand()要注销掉,否则会RE