結果

問題 No.1058 素敵な数
ユーザー TakoKurageTakoKurage
提出日時 2020-05-23 04:27:57
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 247 ms / 2,000 ms
コード長 467 bytes
コンパイル時間 82 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 21,376 KB
最終ジャッジ日時 2024-04-16 02:32:36
合計ジャッジ時間 3,226 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 235 ms
21,376 KB
testcase_01 AC 238 ms
21,248 KB
testcase_02 AC 242 ms
21,376 KB
testcase_03 AC 239 ms
21,248 KB
testcase_04 AC 243 ms
21,248 KB
testcase_05 AC 239 ms
21,120 KB
testcase_06 AC 241 ms
21,248 KB
testcase_07 AC 233 ms
21,248 KB
testcase_08 AC 247 ms
21,376 KB
testcase_09 AC 237 ms
21,248 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def primes(n):
    memo = [True] * (n + 1)
    i = 2
    while i * i <= n:
        if memo[i]:
            j = i << 1
            while j <= n:
                memo[j] = False
                j += i
        i += 1
    return [i for i in range(n + 1) if memo[i] and i >= 10 ** 5 + 1]

from itertools import combinations_with_replacement

N = int(input())

P = primes(10 ** 6)[:N]
A = [1] + sorted(x * y for x, y in combinations_with_replacement(P, 2))

print(A[N - 1])
0