結果

問題 No.106 素数が嫌い!2
ユーザー けーむけーむ
提出日時 2020-03-26 11:15:00
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,200 bytes
コンパイル時間 2,926 ms
コンパイル使用メモリ 173,756 KB
実行使用メモリ 4,508 KB
最終ジャッジ日時 2023-08-30 12:15:20
合計ジャッジ時間 30,680 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n, k;
    cin >> n >> k;
    ll ans = 0;
    vector<bool> checked(n + 1, false);
    reps(i, 2, n + 1) {
        if (checked[i]) continue;
        auto fac = factorize2(i);
        if (sz(fac) >= k) {
            for(ll j = i; j <= n; j += i) {
                checked[j] = true;
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}
0