結果

問題 No.106 素数が嫌い!2
コンテスト
ユーザー koyumeishi
提出日時 2014-12-18 23:36:39
言語 C++11(廃止可能性あり)
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 29 ms / 5,000 ms
コード長 526 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 753 ms
コンパイル使用メモリ 99,596 KB
実行使用メモリ 11,448 KB
最終ジャッジ日時 2026-03-05 05:34:58
合計ジャッジ時間 1,534 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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