結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー tsuchinagatsuchinaga
提出日時 2019-03-08 10:07:28
言語 Go
(1.22.1)
結果
WA  
実行時間 -
コード長 489 bytes
コンパイル時間 10,981 ms
コンパイル使用メモリ 213,228 KB
実行使用メモリ 5,624 KB
最終ジャッジ日時 2023-09-05 19:34:29
合計ジャッジ時間 12,926 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 WA -
testcase_04 AC 1 ms
4,384 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 WA -
testcase_18 AC 1 ms
4,380 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 WA -
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 WA -
testcase_31 AC 2 ms
4,380 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import (
	"fmt"
)

func main() {
	var n, l, cnt int
	_, _ = fmt.Scan(&n, &l)

	p := make([]bool, l/n+2) // 分かりにくいけどfalseが素数
	for i, b := range p {

		// 素数チェック
		if b || i == 0 || i == 1 {
			p[i] = true
			continue
		}

		// 新しい素数を踏んだ場合、その倍数はすべて素数じゃないフラグを立てておく
		for j := i * 2; j < l/n+2; j = j + i {
			p[j] = true
		}

		cnt += l - (n-1)*i + 1
	}
	fmt.Println(cnt)
}
0