結果
| 問題 |
No.2785 四乗足す四の末尾の0
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-06-14 21:48:56 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,380 bytes |
| コンパイル時間 | 326 ms |
| コンパイル使用メモリ | 82,176 KB |
| 実行使用メモリ | 85,376 KB |
| 最終ジャッジ日時 | 2024-06-14 21:49:03 |
| 合計ジャッジ時間 | 5,365 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 15 TLE * 1 -- * 4 |
ソースコード
# 高速素数判定
import random
def Miller_Rabin_fast(n, k):
if n==2: return "prime"
if n%2==0: return "composite"
s, d=0, n-1
while d%2==0:
s, d=s+1, d//2
if n<4759123141:
test=(2,7,61)
for a in test:
if a>n-1: continue
check=[]
check.append(pow(a, d, n)==1)
for r in range(s):
check.append(pow(a, pow(2, r)*d, n)==n-1)
if True in check:
continue
else:
return "composite"
return "prime"
elif n<=pow(2, 64):
test=(2,325,9375,28178,450775,9780504,1795265022)
for a in test:
if a>n-1: continue
check=[]
check.append(pow(a, d, n)==1)
for r in range(s):
check.append(pow(a, pow(2, r)*d, n)==n-1)
if True in check:
continue
else:
return "composite"
return "prime"
else:
for _ in range(k):
a=random.randint(1, n-1)
check=[]
check.append(pow(a, d, n)==1)
for r in range(s):
check.append(pow(a, pow(2, r)*d, n)==n-1)
if True in check:
continue
else:
return "composite"
return "probably_prime"
def ord_10(n):
count=0
while n%10==0 and n>0:
n//=10
count+=1
return count
T=int(input())
for _ in range(T):
N=int(input())
if Miller_Rabin_fast(N*N*N*N+4, 10)!="composite":
print("Yes")
else:
print("No")
print(ord_10(N*N*N*N+4))