結果

問題 No.1058 素敵な数
ユーザー hir355hir355
提出日時 2020-05-22 21:32:28
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 112 ms / 2,000 ms
コード長 600 bytes
コンパイル時間 387 ms
コンパイル使用メモリ 10,796 KB
実行使用メモリ 9,252 KB
最終ジャッジ日時 2023-07-28 06:34:36
合計ジャッジ時間 1,747 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,908 KB
testcase_01 AC 112 ms
9,172 KB
testcase_02 AC 112 ms
9,100 KB
testcase_03 AC 110 ms
9,120 KB
testcase_04 AC 109 ms
9,252 KB
testcase_05 AC 110 ms
9,100 KB
testcase_06 AC 108 ms
9,164 KB
testcase_07 AC 111 ms
9,124 KB
testcase_08 AC 111 ms
9,100 KB
testcase_09 AC 107 ms
9,104 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    for i in range(2, 10 ** 5 + 1):
        is_prime[i] = False
    return [i for i in range(n + 1) if is_prime[i]]


n = int(input())
if n == 1:
    print(1)
else:
    l = []
    for p in primes(10 ** 5 + 100):
        for p2 in primes(10 ** 5 + 100):
            if p <= p2:
                l.append(p * p2)
    l.sort()
    print(l[n - 2])
0