結果
| 問題 | No.2785 四乗足す四の末尾の0 | 
| コンテスト | |
| ユーザー |  高橋ゆに | 
| 提出日時 | 2025-03-17 22:19:27 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                TLE
                                 
                             | 
| 実行時間 | - | 
| コード長 | 908 bytes | 
| コンパイル時間 | 447 ms | 
| コンパイル使用メモリ | 82,876 KB | 
| 実行使用メモリ | 78,732 KB | 
| 最終ジャッジ日時 | 2025-03-17 22:19:39 | 
| 合計ジャッジ時間 | 11,447 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 17 TLE * 3 | 
ソースコード
def main():
    def test_case(N):
        M = N**4 + 4
        print('Yes' if is_prime(M) else 'No')
        ans = 0
        for k in range(40):
            if M % (10**k) == 0:
                ans = k
            else:
                break
        print(ans)
        
    T = int(input())
    for _ in range(T):
        N = int(input())
        test_case(N)
def is_prime(n):
    if n == 2:
        return True
    elif n == 1 or n % 2 == 0:
        return False
    m = n - 1
    lsb = m & -m
    s = lsb.bit_length() - 1
    d = m // lsb
    for a in (2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37):
        if a == n:
            continue
        x = pow(a, d, n)
        r = 0
        if x == 1:
            continue
        while x != m:
            x = pow(x, 2, n)
            r += 1
            if x == 1 or r == s:
                return False
    return True
if __name__ == '__main__':
    main()
            
            
            
        