結果

問題 No.713 素数の和
ユーザー ryusukeryusuke
提出日時 2023-07-09 22:57:32
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 17 ms / 2,000 ms
コード長 525 bytes
コンパイル時間 199 ms
コンパイル使用メモリ 10,716 KB
実行使用メモリ 7,932 KB
最終ジャッジ日時 2023-10-01 03:02:40
合計ジャッジ時間 1,250 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,880 KB
testcase_01 AC 16 ms
7,788 KB
testcase_02 AC 15 ms
7,852 KB
testcase_03 AC 15 ms
7,836 KB
testcase_04 AC 15 ms
7,780 KB
testcase_05 AC 16 ms
7,924 KB
testcase_06 AC 15 ms
7,780 KB
testcase_07 AC 17 ms
7,780 KB
testcase_08 AC 15 ms
7,932 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# verification-helper: PROBLEM https://yukicoder.me/problems/no/713

def primes(n: int) -> list:
    "素数の列挙を行う"

    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(i * 2, n + 1, i):
            is_prime[j] = False

    return [i for i, j in enumerate(is_prime) if j]


def main() -> None:
    print(sum(primes(int(input()))))


if __name__ == "__main__":
    main()
0