結果

問題 No.1498 Factorization from -1 to 1
ユーザー convexineqconvexineq
提出日時 2021-05-05 21:42:39
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,652 ms / 3,000 ms
コード長 660 bytes
コンパイル時間 291 ms
コンパイル使用メモリ 86,892 KB
実行使用メモリ 106,700 KB
最終ジャッジ日時 2023-10-11 15:40:10
合計ジャッジ時間 38,855 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,467 ms
82,116 KB
testcase_01 AC 1,464 ms
82,120 KB
testcase_02 AC 1,464 ms
82,360 KB
testcase_03 AC 1,528 ms
106,184 KB
testcase_04 AC 1,576 ms
106,280 KB
testcase_05 AC 1,637 ms
106,400 KB
testcase_06 AC 1,627 ms
106,440 KB
testcase_07 AC 1,624 ms
106,488 KB
testcase_08 AC 1,652 ms
106,520 KB
testcase_09 AC 1,636 ms
106,700 KB
testcase_10 AC 1,488 ms
82,352 KB
testcase_11 AC 1,490 ms
82,356 KB
testcase_12 AC 1,492 ms
82,376 KB
testcase_13 AC 1,506 ms
89,680 KB
testcase_14 AC 1,507 ms
90,220 KB
testcase_15 AC 1,465 ms
82,088 KB
testcase_16 AC 1,468 ms
82,092 KB
testcase_17 AC 1,480 ms
82,092 KB
testcase_18 AC 1,468 ms
82,252 KB
testcase_19 AC 1,461 ms
82,360 KB
testcase_20 AC 1,462 ms
82,288 KB
testcase_21 AC 1,463 ms
82,196 KB
testcase_22 AC 1,466 ms
82,164 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def Eratosthenes(N): #N以下の素数のリストを返す
    N+=1
    is_prime_list = [True]*N
    m = int(N**0.5)+1
    for i in range(3,m,2):
        if is_prime_list[i]:
            is_prime_list[i*i::2*i]=[False]*((N-i*i-1)//(2*i)+1)
    return [2] + [i for i in range(3,N,2) if is_prime_list[i]]

M = 10**5+2
primes = [i for i in Eratosthenes(M) if i%4 != 3]
lst = [[] for _ in range(M)]
for i in range(1,M):
    x = i*i+1
    for p in primes:
        if p*p > x: break
        while x%p==0:
            lst[i].append(p)
            x //= p
    if x > 1:
        lst[i].append(x)

Q,*qs = map(int,open(0).read().split())
for x in qs:
    print(*lst[x])
0