結果

問題 No.2318 Phys Bone Maker
ユーザー ruthen71
提出日時 2023-05-26 23:29:41
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 2,547 bytes
コンパイル時間 2,000 ms
コンパイル使用メモリ 202,916 KB
最終ジャッジ日時 2025-02-13 08:36:38
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 TLE * 1
other AC * 40 TLE * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
#define REP(i, n) for (int i = 0; i < (n); i++)
template<class T> using V = vector<T>;

template<class T>
ostream &operator<<(ostream &os, const V<T> &v) {
    os << "[ ";
    for (auto &vi: v) os << vi << ", ";
    return os << "]";
}

template<class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    return os << "{ " << p.first << ", " << p.second << "}";
}

#ifdef LOCAL
#define show(x) cerr << __LINE__ << " : " << #x << " = " << x << endl;
#else
#define show(x) true
#endif

using uint = unsigned int;
using ull = unsigned long long;
template <uint MD> struct Modint {
    using M = Modint;
    const static M G;
    uint v;
    Modint(ll val = 0) { set_v(val % MD + MD); }
    M& set_v(uint val) {
        v = (val < MD) ? val : val - MD;
        return *this;
    }
    explicit operator bool() const { return v != 0; }
    M operator-() const { return M() - *this; }
    M operator+(const M& r) const { return M().set_v(v + r.v); }
    M operator-(const M& r) const { return M().set_v(v + MD - r.v); }
    M operator*(const M& r) const { return M().set_v(ull(v) * r.v % MD); }
    M operator/(const M& r) const { return *this * r.inv(); }
    M& operator+=(const M& r) { return *this = *this + r; }
    M& operator-=(const M& r) { return *this = *this - r; }
    M& operator*=(const M& r) { return *this = *this * r; }
    M& operator/=(const M& r) { return *this = *this / r; }
    bool operator==(const M& r) const { return v == r.v; }
    M pow(ll n) const {
        M x = *this, r = 1;
        while (n) {
            if (n & 1) r *= x;
            x *= x;
            n >>= 1;
        }
        return r;
    }
    M inv() const { return pow(MD - 2); }
    friend ostream& operator<<(ostream& os, const M& r) { return os << r.v; }
};
using mint = Modint<998244353>;

int main() {
    long long N;
    cin >> N;
    vector<long long> div;
    for (long long d = 1; d * d <= N; d++) {
        if (N % d == 0) {
            div.push_back(d);
            if (d * d != N) div.push_back(N / d);
        }
    }
    sort(div.begin(), div.end());
    show(div);
    int M = int(div.size());
    vector<mint> dp(M);
    dp[0] = 1;
    REP(i, M) {
        REP(j, M) {
            long long nx = lcm(div[i], div[j]);
            int ind = lower_bound(div.begin(), div.end(), nx) - div.begin();
            if (i >= ind or ind >= M or div[ind] != nx) continue;
            dp[ind] += dp[i];
        }
    }
    cout << dp.back() << '\n';
    return 0;
}
0