結果

問題 No.2785 四乗足す四の末尾の0
ユーザー hiro1729
提出日時 2024-06-14 21:41:20
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 621 bytes
コンパイル時間 385 ms
コンパイル使用メモリ 82,424 KB
実行使用メモリ 86,640 KB
最終ジャッジ日時 2024-06-14 21:41:25
合計ジャッジ時間 5,383 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 15 TLE * 1 -- * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

import random

def Miller_Rabin_test(num):
    if num == 2:
        return True
    if num == 1 or (num > 2 and num & 1 == 0):
        return False

    s, t = 0, num-1
    while t & 1 == 0:
        s, t = s+1, t >> 1
    a = random.randint(1, num-1)
    if pow(a, t, num) == 1:
        return True
    for i in range(0, s):
        if pow(a, pow(2, i) * t, num) == num-1:
            return True
    return False

for _ in range(int(input())):
	N = int(input())
	a = N ** 4 + 4
	if all(Miller_Rabin_test(a) for _ in range(18)):
		print("Yes")
	else:
		print("No")
	c = 0
	while a % 10 == 0:
		c += 1
		a //= 10
	print(c)
0