結果
問題 | No.36 素数が嫌い! |
ユーザー | convexineq |
提出日時 | 2020-11-25 06:43:00 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 780 bytes |
コンパイル時間 | 269 ms |
コンパイル使用メモリ | 87,084 KB |
実行使用メモリ | 71,660 KB |
最終ジャッジ日時 | 2023-10-01 01:39:45 |
合計ジャッジ時間 | 3,876 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 79 ms
71,276 KB |
testcase_01 | AC | 75 ms
71,132 KB |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | AC | 74 ms
70,680 KB |
testcase_09 | AC | 74 ms
71,296 KB |
testcase_10 | AC | 76 ms
71,080 KB |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | AC | 75 ms
71,160 KB |
testcase_15 | AC | 75 ms
71,124 KB |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | AC | 77 ms
71,148 KB |
testcase_19 | AC | 78 ms
71,184 KB |
testcase_20 | AC | 77 ms
70,676 KB |
testcase_21 | AC | 77 ms
71,024 KB |
testcase_22 | AC | 77 ms
71,036 KB |
testcase_23 | AC | 78 ms
71,220 KB |
testcase_24 | AC | 77 ms
71,024 KB |
testcase_25 | AC | 77 ms
71,208 KB |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
ソースコード
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")