結果
| 問題 |
No.8030 ミラー・ラビン素数判定法のテスト
|
| ユーザー |
tSijEG6OkepBhhp
|
| 提出日時 | 2022-12-30 21:24:15 |
| 言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,037 bytes |
| コンパイル時間 | 6,787 ms |
| コンパイル使用メモリ | 156,176 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-11-25 19:48:19 |
| 合計ジャッジ時間 | 7,068 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 4 RE * 6 |
ソースコード
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <math.h>
#include <cassert>
#include <bitset>
#include <map>
#include <algorithm>
#include <iterator>
#include <string>
#include <utility>
#include <numeric>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll=long long;
using P=pair<ll,ll>;
#define reps(i,a,n) for(int i=a;i<n;i++)
#define rep(i,n) reps(i,0,n)
#define all(x) x.begin(),x.end()
vector<ll>a{2,325,9375,28178,450775,9780504,1795265022};
bool solve(ll n){
if(n==1)return 0;
ll d=n-1;
int s=0;
while(d%2==0){d/=2;s++;}
rep(i,7){
if(a[i]%n==0)continue;
ll ad=pow_mod(a[i],d,n);
if(ad==1||ad==n-1)continue;
bool ok=true;
rep(j,s+1){
ad*=ad;
ad%=n;
if(ad==n-1)ok=false;
}
if(ok){
return false;
}
}
return true;
}
int main(){
int n;
cin>>n;
rep(i,n){
ll x;
cin>>x;
cout<<x<<' '<<solve(x)<<endl;
}
}
tSijEG6OkepBhhp