結果

問題 No.106 素数が嫌い!2
コンテスト
ユーザー tkzw_21
提出日時 2014-12-19 00:03:42
言語 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  
実行時間 1,393 ms / 5,000 ms
コード長 506 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 860 ms
コンパイル使用メモリ 103,288 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2026-03-05 05:39:49
合計ジャッジ時間 10,583 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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