結果

問題 No.713 素数の和
ユーザー ohanaohana
提出日時 2023-10-27 15:45:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 37 ms / 2,000 ms
コード長 376 bytes
コンパイル時間 567 ms
コンパイル使用メモリ 81,816 KB
実行使用メモリ 57,008 KB
最終ジャッジ日時 2023-10-27 15:45:59
合計ジャッジ時間 1,363 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
57,008 KB
testcase_01 AC 29 ms
53,584 KB
testcase_02 AC 29 ms
53,584 KB
testcase_03 AC 31 ms
57,008 KB
testcase_04 AC 31 ms
57,008 KB
testcase_05 AC 29 ms
53,584 KB
testcase_06 AC 29 ms
53,584 KB
testcase_07 AC 28 ms
53,584 KB
testcase_08 AC 29 ms
53,584 KB
権限があれば一括ダウンロードができます

ソースコード

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 is_prime, table


print(sum(sieve(int(input()))[1]))
0