結果

問題 No.106 素数が嫌い!2
ユーザー MayimgMayimg
提出日時 2019-01-26 06:42:35
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 23 ms / 5,000 ms
コード長 392 bytes
コンパイル時間 1,240 ms
コンパイル使用メモリ 165,012 KB
実行使用メモリ 11,360 KB
最終ジャッジ日時 2023-10-14 09:56:42
合計ジャッジ時間 2,135 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
11,152 KB
testcase_01 AC 4 ms
11,208 KB
testcase_02 AC 3 ms
11,124 KB
testcase_03 AC 4 ms
11,184 KB
testcase_04 AC 11 ms
11,180 KB
testcase_05 AC 23 ms
11,360 KB
testcase_06 AC 19 ms
11,208 KB
testcase_07 AC 20 ms
11,128 KB
testcase_08 AC 4 ms
11,280 KB
testcase_09 AC 5 ms
11,280 KB
testcase_10 AC 21 ms
11,124 KB
testcase_11 AC 10 ms
11,144 KB
testcase_12 AC 21 ms
11,144 KB
testcase_13 AC 3 ms
11,144 KB
testcase_14 AC 4 ms
11,284 KB
testcase_15 AC 4 ms
11,164 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, k;
	cin >> n >> k;
	int ans = 0;
	int a[2000001] = {};
	for (int i = 2; i <= n; i++) {
		if (!a[i]) {
			for (int j = i;  j <= n; j += i) {
				a[j]++;
			}
		}
	}
	for (int i = 2; i <= n; i++) {
		ans += a[i] >= k;
	}
	cout << ans << endl;
	return 0;
}
0