結果

問題 No.106 素数が嫌い!2
ユーザー koyumeishikoyumeishi
提出日時 2014-12-18 23:36:39
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 38 ms / 5,000 ms
コード長 526 bytes
コンパイル時間 731 ms
コンパイル使用メモリ 76,572 KB
実行使用メモリ 11,016 KB
最終ジャッジ日時 2023-09-02 18:52:51
合計ジャッジ時間 1,724 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
6,904 KB
testcase_01 AC 2 ms
4,368 KB
testcase_02 AC 1 ms
4,368 KB
testcase_03 AC 1 ms
4,372 KB
testcase_04 AC 16 ms
7,284 KB
testcase_05 AC 36 ms
10,980 KB
testcase_06 AC 38 ms
11,016 KB
testcase_07 AC 36 ms
10,984 KB
testcase_08 AC 3 ms
4,368 KB
testcase_09 AC 3 ms
4,368 KB
testcase_10 AC 36 ms
10,996 KB
testcase_11 AC 14 ms
6,612 KB
testcase_12 AC 35 ms
10,768 KB
testcase_13 AC 2 ms
4,372 KB
testcase_14 AC 1 ms
4,372 KB
testcase_15 AC 2 ms
4,372 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<=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