結果

問題 No.1058 素敵な数
ユーザー 👑 H20H20
提出日時 2021-11-25 18:23:04
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 478 bytes
コンパイル時間 376 ms
コンパイル使用メモリ 87,128 KB
実行使用メモリ 78,160 KB
最終ジャッジ日時 2023-09-10 19:56:42
合計ジャッジ時間 2,237 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

def sieve(n):
    is_prime = [True for _ in range(n+1)]
    is_prime[0] = False

    for i in range(2, n+1):
        if is_prime[i-1]:
            j = 2 * i
            while j <= n:
                is_prime[j-1] = False
                j += i
    table = [ i for i in range(1, n+1) if is_prime[i-1]]
    return [False]+is_prime, table


N = int(input())
ANS = [1]
P,T = sieve(10**5+2000)
for i in range(10**5+1,len(P)):
    if P[i]==False:
        ANS.append(i)
print(ANS[N-1])
0