結果

問題 No.106 素数が嫌い!2
ユーザー togatogatogatoga
提出日時 2016-04-26 13:53:22
言語 JavaScript
(node v21.7.1)
結果
AC  
実行時間 4,473 ms / 5,000 ms
コード長 573 bytes
コンパイル時間 237 ms
コンパイル使用メモリ 5,632 KB
実行使用メモリ 43,264 KB
最終ジャッジ日時 2024-04-21 01:20:58
合計ジャッジ時間 28,738 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 912 ms
43,008 KB
testcase_01 AC 65 ms
39,296 KB
testcase_02 AC 64 ms
39,040 KB
testcase_03 AC 64 ms
39,168 KB
testcase_04 AC 1,592 ms
43,008 KB
testcase_05 AC 4,457 ms
43,264 KB
testcase_06 AC 4,473 ms
43,264 KB
testcase_07 AC 4,443 ms
42,880 KB
testcase_08 AC 229 ms
42,880 KB
testcase_09 AC 275 ms
43,136 KB
testcase_10 AC 4,447 ms
42,880 KB
testcase_11 AC 1,619 ms
43,008 KB
testcase_12 AC 4,116 ms
42,752 KB
testcase_13 AC 66 ms
39,168 KB
testcase_14 AC 67 ms
39,296 KB
testcase_15 AC 67 ms
43,008 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

function Main (input) {
	input = input.split("\n");
	input = input[0].split(" ");
	var N = parseInt(input[0], 10);
	var K = parseInt(input[1], 10);
	ans = 0;
	for (var i = 2; i <= N; i++){
		var tmp = i;
		var k = 0;
		for (var j = 2; j * j <= tmp; j++){
			var ok = false;
			while (tmp % j == 0){
				ok = true;
				tmp = Math.floor(tmp / j);
			}
			if (k >= K)break;
			if (ok){
				k += 1;
			}
		}
		if (tmp != 1){
			k += 1;
		}
		// console.log(tmp, k);
		if (k >= K){
			ans += 1;
		}
	}
	console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
0