結果

問題 No.106 素数が嫌い!2
ユーザー fmhrfmhr
提出日時 2015-05-31 06:33:29
言語 Go1.4
(1.4.2)
結果
AC  
実行時間 45 ms / 5,000 ms
コード長 550 bytes
コンパイル時間 220 ms
コンパイル使用メモリ 33,084 KB
実行使用メモリ 17,280 KB
最終ジャッジ日時 2024-05-03 20:22:16
合計ジャッジ時間 1,054 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 21 ms
9,472 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 1 ms
6,944 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 21 ms
9,472 KB
testcase_05 AC 43 ms
17,280 KB
testcase_06 AC 43 ms
17,280 KB
testcase_07 AC 44 ms
17,280 KB
testcase_08 AC 3 ms
6,940 KB
testcase_09 AC 3 ms
6,940 KB
testcase_10 AC 42 ms
17,280 KB
testcase_11 AC 17 ms
8,576 KB
testcase_12 AC 45 ms
16,640 KB
testcase_13 AC 1 ms
6,944 KB
testcase_14 AC 1 ms
6,944 KB
testcase_15 AC 1 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func getPrime(n, k int) {
	m := make([]int, n+1)
	ans := 0
	for i := 2; i <= n; i++ {
		if m[i] == 0 {
			for j := i; j <= n; j += i {
				m[j]++
			}
		}
		if m[i] >= k {
			ans++
		}
	}
	fmt.Println(ans)
	return
}

func main() {
	N := nextInt()
	K := nextInt()
	getPrime(N, K)
}

var s = bufio.NewScanner(os.Stdin)

func next() string {
	s.Split(bufio.ScanWords)
	s.Scan()
	return s.Text()
}
func nextInt() int {
	i, e := strconv.Atoi(next())
	if e != nil {
		panic(e)
	}
	return int(i)
}
0