結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー tsuchinagatsuchinaga
提出日時 2019-03-08 10:54:11
言語 Go
(1.22.1)
結果
AC  
実行時間 200 ms / 1,000 ms
コード長 573 bytes
コンパイル時間 10,366 ms
コンパイル使用メモリ 208,200 KB
実行使用メモリ 7,856 KB
最終ジャッジ日時 2023-09-05 19:34:45
合計ジャッジ時間 12,419 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

package main

import (
	"fmt"
)

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

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

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

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

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