結果

問題 No.1058 素敵な数
ユーザー neterukunneterukun
提出日時 2020-05-23 11:17:23
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 81 ms / 2,000 ms
コード長 831 bytes
コンパイル時間 353 ms
コンパイル使用メモリ 82,688 KB
実行使用メモリ 65,536 KB
最終ジャッジ日時 2024-04-16 17:26:43
合計ジャッジ時間 1,607 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
65,024 KB
testcase_01 AC 79 ms
65,536 KB
testcase_02 AC 78 ms
65,408 KB
testcase_03 AC 77 ms
65,408 KB
testcase_04 AC 77 ms
65,408 KB
testcase_05 AC 79 ms
65,536 KB
testcase_06 AC 77 ms
65,152 KB
testcase_07 AC 81 ms
65,536 KB
testcase_08 AC 79 ms
65,536 KB
testcase_09 AC 78 ms
65,280 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def make_prime_table(n):
    """n以下の非負整数が素数であるかを判定したリストを出力する
    計算量: O(NloglogN)
    入出力例: 6 -> [False, False, True, True, False, True, False]
    """
    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(2 * i, n + 1, i):
            is_prime[j] = False
    return is_prime


table = make_prime_table(10 ** 6)
n = int(input())
if n == 1:
    print(1)
    exit()
n -= 1

primes = []
for i in range(10 ** 5 + 1, 10 ** 6):
    if table[i]:
        primes.append(i)
    if len(primes) == 10:
        break
ans = []
for i in primes:
    for j in primes:
        ans.append(i * j)
ans = sorted(list(set(ans)))
print(ans[n - 1])
0