結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
55,568 KB
testcase_01 AC 36 ms
54,524 KB
testcase_02 AC 39 ms
55,088 KB
testcase_03 AC 39 ms
55,496 KB
testcase_04 AC 36 ms
55,228 KB
testcase_05 AC 36 ms
54,604 KB
testcase_06 AC 36 ms
55,384 KB
testcase_07 AC 36 ms
55,840 KB
testcase_08 AC 36 ms
55,456 KB
testcase_09 AC 37 ms
54,456 KB
testcase_10 AC 41 ms
54,828 KB
testcase_11 AC 35 ms
55,120 KB
testcase_12 AC 40 ms
57,388 KB
testcase_13 AC 90 ms
76,868 KB
testcase_14 AC 298 ms
78,468 KB
testcase_15 AC 1,775 ms
79,360 KB
testcase_16 AC 37 ms
56,216 KB
testcase_17 TLE -
testcase_18 TLE -
testcase_19 TLE -
権限があれば一括ダウンロードができます

ソースコード

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"

import random

def is_prime(n):
    if n == 2: return True
    if n == 1 or n & 1 == 0: return False

    d = (n - 1) >> 1
    while d & 1 == 0:
        d >>= 1

    for k in range(8):
        a = random.randint(1, n - 1)
        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

_10=[10**i for i in range(43)]

def ord_10(n):
  ok = 0
  ng = 42
  while abs(ok-ng)>1:
    mid=(ok+ng)//2
    if n%_10[mid]==0:
      ok=mid
    else:
      ng=mid
  return ok

T=int(input())
for _ in range(T):
  N=int(input())
  if is_prime(N*N*N*N+4):
    print("Yes")
  else:
    print("No")
  print(ord_10(N*N*N*N+4))
0