結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー t8m8⛄️t8m8⛄️
提出日時 2017-05-02 23:31:13
言語 Nim
(2.0.2)
結果
AC  
実行時間 144 ms / 1,000 ms
コード長 500 bytes
コンパイル時間 2,930 ms
コンパイル使用メモリ 68,892 KB
実行使用メモリ 29,928 KB
最終ジャッジ日時 2023-09-12 12:48:36
合計ジャッジ時間 5,887 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 12 ms
5,768 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 127 ms
29,300 KB
testcase_06 AC 67 ms
19,372 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 12 ms
5,860 KB
testcase_20 AC 36 ms
10,652 KB
testcase_21 AC 17 ms
7,228 KB
testcase_22 AC 13 ms
5,892 KB
testcase_23 AC 23 ms
7,816 KB
testcase_24 AC 37 ms
10,772 KB
testcase_25 AC 65 ms
19,216 KB
testcase_26 AC 64 ms
19,080 KB
testcase_27 AC 9 ms
4,784 KB
testcase_28 AC 28 ms
9,952 KB
testcase_29 AC 60 ms
18,932 KB
testcase_30 AC 11 ms
5,620 KB
testcase_31 AC 50 ms
14,244 KB
testcase_32 AC 63 ms
19,124 KB
testcase_33 AC 143 ms
29,744 KB
testcase_34 AC 144 ms
29,928 KB
testcase_35 AC 132 ms
28,848 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import strutils, sequtils

proc sieve(n: int): seq[int] =
  result = newSeq[int]()
  var isPrime = repeat[bool](true, n+1)
  isPrime[0] = false
  isPrime[1] = false
  for i in 2..n:
    if isPrime[i]:
      result.add(i)
      for j in countUp(i+i, n, i):
        isPrime[j] = false

when isMainModule:
  var
    input = stdin.readline.split.map(parseint)
    (n, m) = (input[0], input[1])
    primes = sieve(m)
    ans: int64 = 0

  for p in primes:
    ans += max(0, m - p*(n-1) + 1)
  
  echo ans
0