結果

問題 No.1498 Factorization from -1 to 1
ユーザー GER_chen
提出日時 2021-05-12 00:36:13
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 695 bytes
コンパイル時間 150 ms
コンパイル使用メモリ 82,460 KB
実行使用メモリ 83,624 KB
最終ジャッジ日時 2024-09-22 07:08:54
合計ジャッジ時間 4,943 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3 -- * 3
other TLE * 1 -- * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

#y1498
def E_sieve(n):
    Primes = []
    if n > 1:
        Primes.append(2)
    l = (n-1)//2
    Flag = [True]*l
    for i in range(l):
        p = 2*i+3
        if not Flag[i]:
            continue
        Primes.append(p)
        for i in range((p*p-3)//2, l, p):
            Flag[i] = False
    return Primes
P = [p for p in E_sieve(100001) if p%4 == 1]
for _ in range(int(input())):
    q = int(input())
    Ans = []
    x = q**2+1
    if q&1:
        x //= 2
        Ans.append(2)
    for p in P:
        if p**2 > x:
            break
        if not x%p:
            while not x%p:
                Ans.append(p)
                x //= p
    if x > 1:
        Ans.append(x)
    print(*Ans)
0