結果
| 問題 | 
                            No.2785 四乗足す四の末尾の0
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2024-06-14 22:10:10 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                TLE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,100 bytes | 
| コンパイル時間 | 494 ms | 
| コンパイル使用メモリ | 81,592 KB | 
| 実行使用メモリ | 88,748 KB | 
| 最終ジャッジ日時 | 2024-06-14 22:10:48 | 
| 合計ジャッジ時間 | 9,822 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 18 TLE * 2 | 
ソースコード
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]:
        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)