結果
| 問題 |
No.8114 Prime Checker+1
|
| ユーザー |
kemuniku
|
| 提出日時 | 2025-02-22 03:07:39 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 630 bytes |
| コンパイル時間 | 259 ms |
| コンパイル使用メモリ | 82,176 KB |
| 実行使用メモリ | 157,320 KB |
| 最終ジャッジ日時 | 2025-02-22 03:07:44 |
| 合計ジャッジ時間 | 4,498 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 3 TLE * 1 -- * 26 |
ソースコード
import sys
sys.set_int_max_str_digits(0)
def isprime(N):
bases = [2,1795265022]
if N < 2:
return False
if N == 2:
return True
if N%2 == 0:
return False
N1 = N-1
s,d = (N1 & -N1).bit_length()-1,N1//(N1 & -N1)
for b in bases:
if b % N == 0:
continue
t = pow(b,d,N)
if t == 1 or t == N1:
continue
for _ in range(s-1):
t = pow(t,2,N)
if t == N1:
break
else:
return False
return True
N = int(input())
print(0)
if isprime(N):
print("Yes")
else:
print("No")
kemuniku