結果
| 問題 |
No.36 素数が嫌い!
|
| コンテスト | |
| ユーザー |
convexineq
|
| 提出日時 | 2020-11-25 06:39:57 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 763 bytes |
| コンパイル時間 | 202 ms |
| コンパイル使用メモリ | 82,360 KB |
| 実行使用メモリ | 54,364 KB |
| 最終ジャッジ日時 | 2024-07-23 19:12:11 |
| 合計ジャッジ時間 | 2,317 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 WA * 1 |
| other | AC * 17 WA * 9 |
ソースコード
def isprime_Miller(n):
if n==2: return True
if n==1 or n&1==0: return False
if n < (1<<32): witness = [2,7,61]
else: witness = [2, 325, 9375, 28178, 450775, 9780504, 1795265022] # n < (1<<64) でOK
#elif n < (1<<61): witness = [2,3,5,7,11,13,17,19,23]
#if n in witness: return True
d = n-1
while d&1==0: d >>= 1
for a in witness:
t = d
y = pow(a,t,n)
while t != n-1 and y != 1 and y != n-1:
y = y*y%n
t <<= 1
if y != n-1 and t&1 == 0: return False
return True
# coding: utf-8
# Your code here!
import sys
readline = sys.stdin.readline
read = sys.stdin.read
#a,b,c = map(int,readline().split())
n = int(input())
print("NO" if isprime_Miller(n) else "YES")
convexineq