結果
問題 | No.1498 Factorization from -1 to 1 |
ユーザー |
![]() |
提出日時 | 2021-05-12 00:30:38 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,417 ms / 3,000 ms |
コード長 | 838 bytes |
コンパイル時間 | 321 ms |
コンパイル使用メモリ | 82,220 KB |
実行使用メモリ | 97,296 KB |
最終ジャッジ日時 | 2024-09-22 07:05:28 |
合計ジャッジ時間 | 11,228 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 6 |
other | AC * 17 |
ソースコード
#y1498def E_sieve(n):Primes = []if n > 1:Primes.append(2)l = (n-1)//2Flag = [True]*lfor i in range(l):p = 2*i+3if not Flag[i]:continuePrimes.append(p)for i in range((p*p-3)//2, l, p):Flag[i] = Falsereturn PrimesP = [p for p in E_sieve(100001) if p%4 == 1]Memo = {}for _ in range(int(input())):q = int(input())if Memo.get(q, 0):Ans = Memo[q]else:Ans = []x = q**2+1if q&1:x //= 2Ans.append(2)for p in P:if p**2 > x:breakif not x%p:while not x%p:Ans.append(p)x //= pif x > 1:Ans.append(x)Memo[q] = Ansprint(*Ans)