結果

問題 No.2785 四乗足す四の末尾の0
ユーザー ButterflvButterflv
提出日時 2024-06-14 21:47:42
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,381 bytes
コンパイル時間 240 ms
コンパイル使用メモリ 82,380 KB
実行使用メモリ 86,796 KB
最終ジャッジ日時 2024-06-14 21:47:56
合計ジャッジ時間 5,408 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
59,776 KB
testcase_01 AC 40 ms
54,272 KB
testcase_02 AC 41 ms
54,400 KB
testcase_03 AC 40 ms
54,528 KB
testcase_04 AC 41 ms
54,400 KB
testcase_05 AC 43 ms
54,528 KB
testcase_06 AC 41 ms
54,272 KB
testcase_07 AC 40 ms
54,144 KB
testcase_08 AC 43 ms
54,308 KB
testcase_09 AC 43 ms
54,656 KB
testcase_10 AC 41 ms
54,400 KB
testcase_11 AC 40 ms
54,272 KB
testcase_12 AC 50 ms
60,672 KB
testcase_13 AC 124 ms
75,952 KB
testcase_14 AC 553 ms
77,944 KB
testcase_15 TLE -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

# 高速素数判定
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, 15)!="composite":
    print("Yes")
  else:
    print("No")
  print(ord_10(N*N*N*N+4))
0