結果

問題 No.106 素数が嫌い!2
ユーザー roarisroaris
提出日時 2019-12-20 00:41:56
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 1,968 ms / 5,000 ms
コード長 602 bytes
コンパイル時間 1,669 ms
コンパイル使用メモリ 168,784 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-21 07:52:44
合計ジャッジ時間 15,666 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 773 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 774 ms
4,376 KB
testcase_05 AC 1,964 ms
4,380 KB
testcase_06 AC 1,965 ms
4,380 KB
testcase_07 AC 1,968 ms
4,380 KB
testcase_08 AC 57 ms
4,376 KB
testcase_09 AC 62 ms
4,376 KB
testcase_10 AC 1,966 ms
4,380 KB
testcase_11 AC 651 ms
4,380 KB
testcase_12 AC 1,857 ms
4,376 KB
testcase_13 AC 1 ms
4,384 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;

vector<P> factorize(int n) {
    vector<P> res;
    
    for (int i=2; i*i<=n; i++) {
        int cnt = 0;
        
        while (n%i==0) {
            n /= i;
            cnt++;
        }
        
        if (cnt>0) res.push_back(P(i, cnt));
    }
    
    if (n>1) res.push_back(P(n, 1));
    
    return res;
}

int main() {
    int N, K; cin >> N >> K;
    int ans = 0;
    
    for (int i=2; i<=N; i++) {
        vector<P> fct = factorize(i);
        
        if (fct.size()>=K) ans++;
    }
    
    cout << ans << endl;
}
0