結果

問題 No.106 素数が嫌い!2
ユーザー tkzw_21tkzw_21
提出日時 2014-12-19 00:03:42
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2,211 ms / 5,000 ms
コード長 506 bytes
コンパイル時間 1,766 ms
コンパイル使用メモリ 78,296 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-09-02 19:00:02
合計ジャッジ時間 17,413 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 870 ms
4,372 KB
testcase_01 AC 1 ms
4,368 KB
testcase_02 AC 1 ms
4,372 KB
testcase_03 AC 2 ms
4,368 KB
testcase_04 AC 870 ms
4,372 KB
testcase_05 AC 2,209 ms
4,372 KB
testcase_06 AC 2,211 ms
4,368 KB
testcase_07 AC 2,207 ms
4,368 KB
testcase_08 AC 65 ms
4,372 KB
testcase_09 AC 70 ms
4,368 KB
testcase_10 AC 2,207 ms
4,372 KB
testcase_11 AC 736 ms
4,368 KB
testcase_12 AC 2,089 ms
4,372 KB
testcase_13 AC 2 ms
4,368 KB
testcase_14 AC 2 ms
4,368 KB
testcase_15 AC 2 ms
4,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cmath>
#include <vector>
#include <utility>
#include <queue>
#include <map>
#include <algorithm>

using namespace std;

int prime_factor(int n){
	map<int,int>res;
	int cnt = 0;
	for(int i=2;i*i<=n;i++){
		while(n%i==0){
			++res[i];
			if(res[i] == 1)cnt++;
			n /= i;
		}
	}
	if(n!=1){
		res[n]=1;
		cnt++;
	}
	return cnt;
}

int main(void){
	int n,k;
	cin >> n >> k;
	int ret =0;
	for(int i=2;i<=n;i++){
		if(prime_factor(i) >= k)ret++;
	}
	cout << ret << endl;
	return 0;
}
0