結果

問題 No.407 鴨等素数間隔列の数え上げ
コンテスト
ユーザー むらため
提出日時 2019-01-23 20:25:46
言語 Nim
(2.2.8)
コンパイル:
nim --nimcache=~ --hints:off -o:a.out -d:release cpp _filename_
実行:
./a.out
結果
AC  
実行時間 86 ms / 1,000 ms
コード長 568 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,850 ms
コンパイル使用メモリ 68,408 KB
実行使用メモリ 13,492 KB
最終ジャッジ日時 2026-03-22 09:31:05
合計ジャッジ時間 3,315 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 31
権限があれば一括ダウンロードができます
コンパイルメッセージ
/home/judge/data/code/Main.nim(1, 8) Warning: imported and not used: 'sequtils' [UnusedImport]

ソースコード

diff #
raw source code

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