結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー むらため
提出日時 2019-01-23 20:25:46
言語 Nim
(2.2.0)
結果
AC  
実行時間 92 ms / 1,000 ms
コード長 568 bytes
コンパイル時間 2,366 ms
コンパイル使用メモリ 60,972 KB
実行使用メモリ 12,752 KB
最終ジャッジ日時 2024-07-01 10:38:44
合計ジャッジ時間 4,062 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 31
権限があれば一括ダウンロードができます
コンパイルメッセージ
/home/judge/data/code/Main.nim(1, 8) Warning: imported and not used: 'sequtils' [UnusedImport]

ソースコード

diff #

import sequtils,math

proc getchar_unlocked():char {. importc:"getchar_unlocked",header: "<stdio.h>" .}
proc scan(): int =
  while true:
    let k = getchar_unlocked()
    if k < '0': break
    result = 10 * result + k.ord - '0'.ord
let n = scan()
let k = scan()
if k == 0 : quit "0",0
var isNotPrimes : array[1000_0010,bool]
for i in 2..k.float.sqrt.int:
  if isNotPrimes[i] : continue
  for j in countup(i*2,k,i):
    isNotPrimes[j] = true

var ans = 0
for i in 2..k:
  if isNotPrimes[i] : continue
  let a = 1 + k - i * (n-1)
  if a <= 0 : break
  ans += a
echo ans
0