結果

問題 No.106 素数が嫌い!2
ユーザー fmhrfmhr
提出日時 2015-05-31 06:14:40
言語 Go
(1.22.1)
結果
AC  
実行時間 50 ms / 5,000 ms
コード長 392 bytes
コンパイル時間 12,471 ms
コンパイル使用メモリ 224,320 KB
実行使用メモリ 19,456 KB
最終ジャッジ日時 2024-04-19 02:15:40
合計ジャッジ時間 11,671 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 20 ms
10,624 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 21 ms
10,624 KB
testcase_05 AC 48 ms
19,456 KB
testcase_06 AC 47 ms
19,456 KB
testcase_07 AC 48 ms
19,456 KB
testcase_08 AC 3 ms
5,376 KB
testcase_09 AC 3 ms
5,376 KB
testcase_10 AC 46 ms
19,456 KB
testcase_11 AC 17 ms
9,600 KB
testcase_12 AC 50 ms
18,816 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import "fmt"

func getPrime(n, k int) {
	p := make([]bool, n+1) // false: 素数の可能性有 true: notPrime
	m := make([]int, n+1)
	ans := 0
	for i := 2; i <= n; i++ {
		if !p[i] {
			for j := i; j <= n; j += i {
				p[j] = true
				m[j]++
			}
		}
		if m[i] >= k {
			ans++
		}
	}
	fmt.Println(ans)
	return
}

func main() {
	var N, K int
	fmt.Scan(&N, &K)
	getPrime(N, K)
}
0