結果
問題 | No.2785 四乗足す四の末尾の0 |
ユーザー |
|
提出日時 | 2024-06-14 22:11:57 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,913 ms / 2,000 ms |
コード長 | 1,022 bytes |
コンパイル時間 | 435 ms |
コンパイル使用メモリ | 82,404 KB |
実行使用メモリ | 86,912 KB |
最終ジャッジ日時 | 2024-06-14 22:12:08 |
合計ジャッジ時間 | 9,023 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 20 |
ソースコード
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]: 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: cnt = 0 while N % 10 == 0: cnt += 1 N //= 10 print(cnt)