結果

問題 No.106 素数が嫌い!2
ユーザー GOTKAKO
提出日時 2025-07-03 16:16:29
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 1,163 ms / 5,000 ms
コード長 706 bytes
コンパイル時間 1,682 ms
コンパイル使用メモリ 203,708 KB
実行使用メモリ 145,044 KB
最終ジャッジ日時 2025-07-03 16:16:58
合計ジャッジ時間 21,492 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int Need = 2000000;
    vector<vector<pair<int,int>>> Pf(Need+1);
    vector<bool> prime(Need+1,true);
    prime.at(0) = false; prime.at(1) = false;
    for(int i=2; i<=Need; i++){
        if(!prime.at(i)) continue;
        Pf.at(i) = {{i,1}};
        for(int k=i+i; k<=Need; k+=i){
            prime.at(k) = false;
            int f = 0,k2 = k;
            while(k2%i == 0) f++,k2 /= i;
            Pf.at(k).push_back({i,f});
        }
    }
    int N,K; cin >> N >> K;
    int answer = 0;
    for(int i=2; i<=N; i++) answer += Pf.at(i).size()>=K;
    cout << answer << endl;
}
0