#include<bits/stdc++.h> using namespace std; long long quick_mod(long long a,long long b,int m) { long long ans = 1; while(b!=0) { if(b&1) ans = (ans * a)%m; a = (a*a)%m; b /= 2; } return ans; } bool rqui_prime(int x)//x不能超int /// shizhushuyes = true { srand(time(0)); int n = log(x)+7; if(quick_mod(7,x-1,x) != 1) { return false; } for(int i = 0; i < n; i++) { long long k = rand()%10000+7; if((k%x)&&(quick_mod(k,x-1,x)!=1)) { return false; } } return true; }
[模板] - 大质数判定
猜你喜欢
转载自blog.csdn.net/yiranluoshen/article/details/78681974
今日推荐
周排行