結果

問題 No.106 素数が嫌い!2
ユーザー masa
提出日時 2015-05-25 03:07:48
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 20 ms / 5,000 ms
コード長 399 bytes
コンパイル時間 496 ms
コンパイル使用メモリ 61,504 KB
実行使用メモリ 11,068 KB
最終ジャッジ日時 2024-07-06 08:09:39
合計ジャッジ時間 1,253 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

int main() {
	int n, k;
	int ans = 0;

	cin >> n >> k;
	vector<int> a(n + 1, 0);
	for (int i = 2; i <= n; i++) {
		if (a[i] == 0) {
			for (int j = i; j <= n; j += i) {
				a[j]++;
			}
		}

		if (a[i] >= k) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}
0