結果

問題 No.2318 Phys Bone Maker
ユーザー Yilin FeiYilin Fei
提出日時 2024-01-08 18:02:32
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 375 ms / 3,000 ms
コード長 1,725 bytes
コンパイル時間 1,818 ms
コンパイル使用メモリ 178,528 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-01-08 18:02:39
合計ジャッジ時間 6,594 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 375 ms
6,676 KB
testcase_03 AC 7 ms
6,676 KB
testcase_04 AC 9 ms
6,676 KB
testcase_05 AC 9 ms
6,676 KB
testcase_06 AC 8 ms
6,676 KB
testcase_07 AC 3 ms
6,676 KB
testcase_08 AC 8 ms
6,676 KB
testcase_09 AC 7 ms
6,676 KB
testcase_10 AC 13 ms
6,676 KB
testcase_11 AC 10 ms
6,676 KB
testcase_12 AC 13 ms
6,676 KB
testcase_13 AC 11 ms
6,676 KB
testcase_14 AC 10 ms
6,676 KB
testcase_15 AC 9 ms
6,676 KB
testcase_16 AC 11 ms
6,676 KB
testcase_17 AC 12 ms
6,676 KB
testcase_18 AC 12 ms
6,676 KB
testcase_19 AC 5 ms
6,676 KB
testcase_20 AC 10 ms
6,676 KB
testcase_21 AC 8 ms
6,676 KB
testcase_22 AC 7 ms
6,676 KB
testcase_23 AC 9 ms
6,676 KB
testcase_24 AC 11 ms
6,676 KB
testcase_25 AC 12 ms
6,676 KB
testcase_26 AC 10 ms
6,676 KB
testcase_27 AC 11 ms
6,676 KB
testcase_28 AC 7 ms
6,676 KB
testcase_29 AC 7 ms
6,676 KB
testcase_30 AC 8 ms
6,676 KB
testcase_31 AC 13 ms
6,676 KB
testcase_32 AC 17 ms
6,676 KB
testcase_33 AC 2 ms
6,676 KB
testcase_34 AC 10 ms
6,676 KB
testcase_35 AC 44 ms
6,676 KB
testcase_36 AC 182 ms
6,676 KB
testcase_37 AC 180 ms
6,676 KB
testcase_38 AC 184 ms
6,676 KB
testcase_39 AC 276 ms
6,676 KB
testcase_40 AC 275 ms
6,676 KB
testcase_41 AC 316 ms
6,676 KB
testcase_42 AC 311 ms
6,676 KB
testcase_43 AC 13 ms
6,676 KB
testcase_44 AC 47 ms
6,676 KB
testcase_45 AC 43 ms
6,676 KB
testcase_46 AC 319 ms
6,676 KB
testcase_47 AC 23 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 998244353;

vector<pair<ll, ll>> Prime_factorization(ll val) {
    vector<pair<ll, ll>> ans;
    for (ll i = 2; i * i <= val; i++) {
        if (val % i == 0) {
            ans.emplace_back(i, 0);
            while (val % i == 0) {
                ans.back().second++;
                val /= i;
            }
        }
    }
    if (val != 1) ans.emplace_back(val, 1);
    return ans;
}

vector<ll> Divisors(ll N) {
    vector<ll> p, q;
    for (ll i = 1; i * i <= N; i++) {
        if (N % i == 0) {
            p.push_back(i);
            if (i != N / i) q.push_back(N / i);
        }
    }
    for (auto it = q.rbegin(); it != q.rend(); ++it) p.push_back(*it);
    return p;
}

void solve() {
    ll N;
    cin >> N;
    auto D = Divisors(N);
    auto E = Prime_factorization(N);
    vector<vector<ll>> p(D.size(), vector<ll>(E.size()));
    for (size_t i = 0; i < D.size(); i++) for (size_t j = 0; j < E.size(); j++) {
        ll tmp = D[i], count = 0;
        while (tmp % E[j].first == 0) {
            tmp /= E[j].first;
            count++;
        }
        p[i][j] = count;
    }
    vector<ll> dp(D.size(), 0);
    dp[0] = 1;
    for (size_t i = 0; i < D.size(); i++) for (size_t j = i + 1; j < D.size(); j++) {
        if (D[j] % D[i] == 0) {
            ll tmp = 1;
            for (size_t k = 0; k < E.size(); k++) {
                if (p[i][k] == p[j][k]) {
                    tmp = (tmp * (1 + p[i][k])) % mod;
                }
            }
            dp[j] = (dp[j] + dp[i] * tmp) % mod;
        }
    }
    cout << dp.back() << "\n";
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
}
0