結果

問題 No.1058 素敵な数
ユーザー nephrologistnephrologist
提出日時 2020-05-22 22:13:08
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 40 ms / 2,000 ms
コード長 685 bytes
コンパイル時間 90 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 14,060 KB
最終ジャッジ日時 2024-04-15 17:05:04
合計ジャッジ時間 929 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,752 KB
testcase_01 AC 36 ms
13,928 KB
testcase_02 AC 40 ms
13,932 KB
testcase_03 AC 36 ms
13,928 KB
testcase_04 AC 39 ms
13,928 KB
testcase_05 AC 36 ms
13,804 KB
testcase_06 AC 36 ms
13,936 KB
testcase_07 AC 37 ms
13,932 KB
testcase_08 AC 36 ms
13,932 KB
testcase_09 AC 37 ms
14,060 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
if n == 1:
    print(1)
    exit()
N = 2 * (10 ** 5)


def prime_hantei(n):
    kouho = []
    is_prime = [0] * (n + 1)
    is_prime[2] = 1
    len3 = len(is_prime[3::2])
    is_prime[3::2] = [1] * (len3)
    for i in range(3, int(n ** 0.5) + 1, 2):
        if is_prime[i]:
            len_is = len(is_prime[i * i :: i + i])
            is_prime[i * i :: i + i] = [0] * len_is
    for j in range(10 ** 5 + 1, 10 ** 5 + 10 ** 2):
        if is_prime[j] == 1:
            kouho.append(j)
    return kouho


kouho = prime_hantei(N)
ans = []
for a in kouho:
    for b in kouho:
        ans.append(a * b)
ans = list(set(ans))
ans.sort()
ans = [0] + [1] + ans
print(ans[n])
0