結果

問題 No.106 素数が嫌い!2
ユーザー latte0119latte0119
提出日時 2015-05-04 13:40:37
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 52 ms / 5,000 ms
コード長 480 bytes
コンパイル時間 722 ms
コンパイル使用メモリ 60,140 KB
実行使用メモリ 13,412 KB
最終ジャッジ日時 2023-09-19 06:42:45
合計ジャッジ時間 2,924 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
13,080 KB
testcase_01 AC 48 ms
13,124 KB
testcase_02 AC 50 ms
13,392 KB
testcase_03 AC 44 ms
13,108 KB
testcase_04 AC 46 ms
13,108 KB
testcase_05 AC 47 ms
13,088 KB
testcase_06 AC 47 ms
13,108 KB
testcase_07 AC 49 ms
13,108 KB
testcase_08 AC 45 ms
13,148 KB
testcase_09 AC 46 ms
13,140 KB
testcase_10 AC 48 ms
13,412 KB
testcase_11 AC 47 ms
13,108 KB
testcase_12 AC 52 ms
13,088 KB
testcase_13 AC 45 ms
13,104 KB
testcase_14 AC 52 ms
13,256 KB
testcase_15 AC 45 ms
13,176 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
int cnt[2000001];
bool f[2000001];
int main(){

	fill_n(f, 2000001, true);
	f[0] = f[1] = false;
	for (int i = 2; i <= 2000000; i++){
		if (!f[i])continue;
		cnt[i]++;
		for (int j = i + i; j <= 2000000; j += i){
			cnt[j]++;
			f[j] = false;
		}
	}

	int N, K;
	cin >> N >> K;
	int ans = 0;
	for (int i = 2; i <= N; i++){
		if (cnt[i] >= K)ans++;
	}
	cout << ans << endl;
	return 0;

}
0