結果

問題 No.2785 四乗足す四の末尾の0
ユーザー Shirotsume
提出日時 2024-06-14 22:09:10
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,132 bytes
コンパイル時間 224 ms
コンパイル使用メモリ 82,552 KB
実行使用メモリ 89,276 KB
最終ジャッジ日時 2024-06-14 22:09:21
合計ジャッジ時間 10,655 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 17 TLE * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys, time, random
from collections import deque, Counter, defaultdict
input = lambda: sys.stdin.readline().rstrip()
ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(mi())
inf = 2 ** 61 - 1
mod = 998244353

from math import gcd
def isprime(n):
    if n <= 2:
        return n == 2
    if n % 2 == 0:
        return False
    s = 0
    t = n - 1
    while t % 2 == 0:
        s += 1
        t //= 2
    
    for a in [2,325,9375,28178,450775,9780504,1795265022]:
        if a >= n:
            break
        x = pow(a, t, n)
        if x == 1 or x == n - 1:
            continue
        for _ in range(s):
            x = (x * x) % n
            if x == n - 1:
                break
        if x == n - 1:
            continue

        return False
    return True

for _ in range(ii()):
    n =ii()
    N = n ** 4 + 4
    p = isprime(N)
    print('Yes' if p else 'No')
    if p:
        print(0)
    else:
        N = str(N)
        cnt = 0
        for i in range(1, len(N) + 1):
            if N[-i] == '0':
                cnt += 1
            else:
                break
        print(cnt)
0