质数判定
题目描述
判定输入的数是不是质数。
输入格式
若干行,一行一个数 。
行数不超过 105。
输出格式
对于输入的每一行,如果 是质数输出一行 Y,否则输出一行 N。
样例
样例输入
1
2
6
9
666623333
样例输出
N
Y
N
N
Y
数据范围与提示
1 <= x <= 1 * 1018
欢迎hack(如果你不是管理员,可以在题目讨论区发帖)。
Miller_rabin 详解链接
Miller_rabin算法
优势可以单独判断一个大数是否素数。
缺点他是一个不保证正确的算法,我们只能通过多次执行算法让这个错误的概率很小,不过幸运的是通常来看它的错误概率可以小到忽略不计。
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <map>
using namespace std;
const int times = 13;
int number = 0;
map<long long, int>m;
long long Random