結果
問題 |
No.407 鴨等素数間隔列の数え上げ
|
ユーザー |
|
提出日時 | 2019-01-23 20:28:51 |
言語 | Nim (2.2.0) |
結果 |
AC
|
実行時間 | 52 ms / 1,000 ms |
コード長 | 616 bytes |
コンパイル時間 | 2,514 ms |
コンパイル使用メモリ | 61,304 KB |
実行使用メモリ | 8,276 KB |
最終ジャッジ日時 | 2024-07-01 10:38:52 |
合計ジャッジ時間 | 3,776 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 31 |
コンパイルメッセージ
/home/judge/data/code/Main.nim(1, 8) Warning: imported and not used: 'sequtils' [UnusedImport]
ソースコード
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] var ans = 0 let primeMax = k div (n-1) for i in 2..primeMax.float.sqrt.int: if isNotPrimes[i] : continue for j in countup(i*2,primeMax,i): isNotPrimes[j] = true for i in 2..primeMax: if isNotPrimes[i] : continue let a = 1 + k - i * (n-1) if a <= 0 : break ans += a echo ans