結果
問題 |
No.2785 四乗足す四の末尾の0
|
ユーザー |
|
提出日時 | 2024-06-14 22:11:27 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,031 bytes |
コンパイル時間 | 172 ms |
コンパイル使用メモリ | 82,140 KB |
実行使用メモリ | 87,008 KB |
最終ジャッジ日時 | 2024-06-14 22:11:39 |
合計ジャッジ時間 | 10,441 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 17 TLE * 3 |
ソースコード
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: cnt = 0 while N % 10 == 0: cnt += 1 N //= 10 print(cnt)