結果

問題 No.106 素数が嫌い!2
ユーザー koyumeishikoyumeishi
提出日時 2014-12-18 23:31:59
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 528 bytes
コンパイル時間 2,386 ms
コンパイル使用メモリ 75,828 KB
実行使用メモリ 11,180 KB
最終ジャッジ日時 2023-09-02 18:52:49
合計ジャッジ時間 1,808 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
6,912 KB
testcase_01 WA -
testcase_02 AC 2 ms
4,368 KB
testcase_03 AC 2 ms
4,368 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 25 ms
11,012 KB
testcase_07 AC 26 ms
10,988 KB
testcase_08 WA -
testcase_09 AC 3 ms
4,372 KB
testcase_10 AC 25 ms
11,012 KB
testcase_11 AC 11 ms
6,540 KB
testcase_12 WA -
testcase_13 AC 2 ms
4,372 KB
testcase_14 AC 2 ms
4,372 KB
testcase_15 AC 2 ms
4,368 KB
権限があれば一括ダウンロードができます

ソースコード

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*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