結果

問題 No.1498 Factorization from -1 to 1
ユーザー GER_chenGER_chen
提出日時 2021-05-12 00:34:19
言語 PyPy3
(7.3.13)
結果
TLE  
実行時間 -
コード長 670 bytes
コンパイル時間 143 ms
コンパイル使用メモリ 81,820 KB
実行使用メモリ 66,716 KB
最終ジャッジ日時 2023-10-22 05:47:48
合計ジャッジ時間 5,117 ms
ジャッジサーバーID
(参考情報)
judge10 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 49 ms
66,716 KB
testcase_01 AC 50 ms
62,368 KB
testcase_02 AC 52 ms
64,696 KB
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
権限があれば一括ダウンロードができます

ソースコード

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 = E_sieve(100001)
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