結果
問題 |
No.36 素数が嫌い!
|
ユーザー |
![]() |
提出日時 | 2020-11-25 06:43:00 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 780 bytes |
コンパイル時間 | 318 ms |
コンパイル使用メモリ | 81,836 KB |
実行使用メモリ | 54,352 KB |
最終ジャッジ日時 | 2024-07-23 19:12:14 |
合計ジャッジ時間 | 2,476 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 2 |
other | AC * 13 WA * 13 |
ソースコード
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()) n = 1<<33 print("NO" if isprime_Miller(n) or n==1 else "YES")