結果

問題 No.1058 素敵な数
ユーザー NatsubiSoganNatsubiSogan
提出日時 2020-08-28 19:27:39
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 41 ms / 2,000 ms
コード長 628 bytes
コンパイル時間 124 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 11,392 KB
最終ジャッジ日時 2024-04-26 12:28:22
合計ジャッジ時間 1,031 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
11,392 KB
testcase_01 AC 41 ms
11,264 KB
testcase_02 AC 39 ms
11,264 KB
testcase_03 AC 35 ms
11,392 KB
testcase_04 AC 38 ms
11,392 KB
testcase_05 AC 36 ms
11,264 KB
testcase_06 AC 36 ms
11,264 KB
testcase_07 AC 36 ms
11,264 KB
testcase_08 AC 36 ms
11,264 KB
testcase_09 AC 37 ms
11,392 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
def is_prime(x):
    if x < 2:
        return False
    if x == 2 or x == 3 or x == 5:
        return True
    if x % 2 == 0 or x % 3 == 0 or x % 5 == 0:
        return False
    prime_number = 7
    difference = 4
    while prime_number <= math.sqrt(x):
        if x % prime_number == 0:
            return False
        prime_number += difference
        difference = 6 - difference
    return True
n = int(input())
l = []
for i in range(10 ** 5, 10 ** 5 + 1000):
    if is_prime(i):
        l.append(i)
ans = [1]
for i in l:
    for j in l:
        ans.append(i * j)
ans = sorted(list(set(ans)))
print(ans[n - 1])
0