結果

問題 No.106 素数が嫌い!2
ユーザー koyumeishi
提出日時 2014-12-18 23:36:39
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 49 ms / 5,000 ms
コード長 526 bytes
コンパイル時間 795 ms
コンパイル使用メモリ 76,080 KB
実行使用メモリ 11,264 KB
最終ジャッジ日時 2024-06-12 01:20:16
合計ジャッジ時間 1,670 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cstdio>
#include <sstream>
#include <map>
#include <string>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;


int main(){
	int N,K;
	cin >> N >> K;
	vector<int> v(N+1, 0);
	vector<bool> p(N+1, true);
	for(long long i=2; i<=N; ++i){
		if(p[i] == false) continue;
		for(int j=i+i; j<=N; j+=i){
			v[j]++;
			p[j] = false;
		}
	}

	long long ans = 0;
	for(int i=2; i<=N; i++){
		ans += (v[i]+(p[i]?1:0))>=K?1:0;
	}

	cout << ans << endl;
	
	return 0;
}
0