結果

問題 No.1058 素敵な数
ユーザー maspymaspy
提出日時 2023-05-12 21:13:21
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 123 ms / 2,000 ms
コード長 517 bytes
コンパイル時間 369 ms
コンパイル使用メモリ 10,936 KB
実行使用メモリ 30,056 KB
最終ジャッジ日時 2023-08-19 03:33:43
合計ジャッジ時間 2,399 ms
ジャッジサーバーID
(参考情報)
judge11 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
29,992 KB
testcase_01 AC 120 ms
29,956 KB
testcase_02 AC 123 ms
30,000 KB
testcase_03 AC 118 ms
29,840 KB
testcase_04 AC 120 ms
30,024 KB
testcase_05 AC 123 ms
29,956 KB
testcase_06 AC 123 ms
30,056 KB
testcase_07 AC 118 ms
29,932 KB
testcase_08 AC 120 ms
29,972 KB
testcase_09 AC 120 ms
30,016 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(read())

U = 10**5 + 1000
is_prime = np.zeros(U, np.bool_)
is_prime[2] = 1
is_prime[3::2] = 1
for p in range(3, U, 2):
    if p * p > U:
        break
    if is_prime[p]:
        is_prime[p * p::p + p] = 0
primes = np.where(is_prime)[0]

primes = primes[primes > 10**5]

se = set(x * y for x in primes for y in primes)
se.add(1)

nums = sorted(se)[:10]

print(nums[N - 1])
0