結果

問題 No.713 素数の和
ユーザー brthyyjpbrthyyjp
提出日時 2020-03-21 12:04:41
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 75 ms / 2,000 ms
コード長 352 bytes
コンパイル時間 313 ms
コンパイル使用メモリ 87,184 KB
実行使用メモリ 75,708 KB
最終ジャッジ日時 2023-08-23 10:33:29
合計ジャッジ時間 1,778 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
75,700 KB
testcase_01 AC 70 ms
71,420 KB
testcase_02 AC 72 ms
72,056 KB
testcase_03 AC 72 ms
71,452 KB
testcase_04 AC 74 ms
75,708 KB
testcase_05 AC 73 ms
71,860 KB
testcase_06 AC 73 ms
71,940 KB
testcase_07 AC 71 ms
71,472 KB
testcase_08 AC 73 ms
71,604 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def sieve(n):
  ass = []
  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
  for i in range(n+1):
    if is_prime[i]:
      ass.append(i)
  return(ass)

n = int(input())
l = sieve(n)
print(sum(l))
0