結果
問題 | 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, randomfrom collections import deque, Counter, defaultdictinput = lambda: sys.stdin.readline().rstrip()ii = lambda: int(input())mi = lambda: map(int, input().split())li = lambda: list(mi())inf = 2 ** 61 - 1mod = 998244353from math import gcddef isprime(n):if n <= 2:return n == 2if n % 2 == 0:return Falses = 0t = n - 1while t % 2 == 0:s += 1t //= 2for a in [2,325,9375]:if a >= n:breakx = pow(a, t, n)if x == 1 or x == n - 1:continuefor _ in range(s):x = (x * x) % nif x == n - 1:breakif x == n - 1:continuereturn Falsereturn Truefor _ in range(ii()):n =ii()N = n ** 4 + 4p = isprime(N)print('Yes' if p else 'No')if p:print(0)else:N = str(N)cnt = 0for i in range(1, len(N) + 1):if N[-i] == '0':cnt += 1else:breakprint(cnt)