結果

問題 No.2785 四乗足す四の末尾の0
ユーザー ra5anchorra5anchor
提出日時 2024-06-14 22:24:34
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 857 bytes
コンパイル時間 169 ms
コンパイル使用メモリ 81,884 KB
実行使用メモリ 79,884 KB
最終ジャッジ日時 2024-06-14 22:24:45
合計ジャッジ時間 10,652 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
51,968 KB
testcase_01 AC 36 ms
52,308 KB
testcase_02 AC 36 ms
52,352 KB
testcase_03 AC 35 ms
51,968 KB
testcase_04 AC 33 ms
52,480 KB
testcase_05 AC 35 ms
51,968 KB
testcase_06 AC 36 ms
52,224 KB
testcase_07 AC 33 ms
52,352 KB
testcase_08 AC 35 ms
51,968 KB
testcase_09 AC 35 ms
52,224 KB
testcase_10 AC 35 ms
51,968 KB
testcase_11 AC 37 ms
52,736 KB
testcase_12 AC 41 ms
55,552 KB
testcase_13 AC 91 ms
76,160 KB
testcase_14 AC 271 ms
76,672 KB
testcase_15 AC 1,691 ms
77,632 KB
testcase_16 AC 34 ms
52,736 KB
testcase_17 TLE -
testcase_18 TLE -
testcase_19 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import math

def suspect(a, t, n):
    x = pow(a, t, n)
    n1 = n - 1
    while t != n1 and x != 1 and x != n1:
        x = pow(x, 2, n)
        t <<= 1
    return t & 1 or x == n1

def miller_rabin(n):
    if n == 2:
        return True
    if n < 2 or n % 2 == 0:
        return False
    d = (n - 1) >> 1
    while d & 1 == 0:
        d >>= 1
    check_list = (2, 7, 61) if n < 2 ** 32 else (2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37)
    for i in check_list:
        if i >= n:
            break
        if not suspect(i, d, n):
            return False
    return True




T = int(input())
for t in range(T):
    N = int(input())
    res = miller_rabin(N**4+4)
    if res == True:
        print('Yes')
    else:
        print('No')
    # print(ans)
    x = N**4 + 4
    cnt = 0
    while x % 10 == 0:
        x //= 10
        cnt += 1
    print(cnt)
0