結果

問題 No.2318 Phys Bone Maker
ユーザー t98slidert98slider
提出日時 2023-05-26 22:25:40
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 3,665 bytes
コンパイル時間 1,622 ms
コンパイル使用メモリ 178,484 KB
実行使用メモリ 196,520 KB
最終ジャッジ日時 2023-08-26 12:28:20
合計ジャッジ時間 25,750 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 6 ms
4,380 KB
testcase_04 AC 7 ms
4,380 KB
testcase_05 AC 8 ms
4,376 KB
testcase_06 AC 7 ms
4,376 KB
testcase_07 AC 3 ms
4,376 KB
testcase_08 AC 6 ms
4,380 KB
testcase_09 AC 6 ms
4,384 KB
testcase_10 AC 11 ms
4,376 KB
testcase_11 AC 8 ms
4,380 KB
testcase_12 AC 11 ms
4,376 KB
testcase_13 AC 11 ms
4,380 KB
testcase_14 AC 8 ms
4,380 KB
testcase_15 AC 8 ms
4,380 KB
testcase_16 AC 7 ms
4,380 KB
testcase_17 AC 10 ms
4,384 KB
testcase_18 AC 10 ms
4,376 KB
testcase_19 AC 5 ms
4,380 KB
testcase_20 AC 8 ms
4,376 KB
testcase_21 AC 7 ms
4,376 KB
testcase_22 AC 6 ms
4,380 KB
testcase_23 AC 7 ms
4,380 KB
testcase_24 AC 10 ms
4,376 KB
testcase_25 AC 8 ms
4,380 KB
testcase_26 AC 9 ms
4,380 KB
testcase_27 AC 9 ms
4,380 KB
testcase_28 AC 6 ms
4,380 KB
testcase_29 AC 6 ms
4,376 KB
testcase_30 AC 5 ms
4,380 KB
testcase_31 AC 11 ms
4,376 KB
testcase_32 AC 10 ms
4,380 KB
testcase_33 AC 1 ms
4,380 KB
testcase_34 AC 9 ms
4,376 KB
testcase_35 AC 336 ms
21,144 KB
testcase_36 AC 1,815 ms
120,856 KB
testcase_37 AC 1,834 ms
120,052 KB
testcase_38 AC 1,823 ms
118,816 KB
testcase_39 AC 2,931 ms
176,844 KB
testcase_40 AC 2,872 ms
177,936 KB
testcase_41 TLE -
testcase_42 TLE -
testcase_43 AC 13 ms
4,376 KB
testcase_44 AC 279 ms
20,148 KB
testcase_45 AC 259 ms
19,364 KB
testcase_46 TLE -
testcase_47 AC 11 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

template<const unsigned int MOD> struct prime_modint {
    using mint = prime_modint;
    unsigned int v;
    prime_modint() : v(0) {}
    prime_modint(unsigned int a) { a %= MOD; v = a; }
    prime_modint(unsigned long long a) { a %= MOD; v = a; }
    prime_modint(int a) { a %= (int)(MOD); if(a < 0)a += MOD; v = a; }
    prime_modint(long long a) { a %= (int)(MOD); if(a < 0)a += MOD; v = a; }
    static constexpr int mod() { return MOD; }
    mint& operator++() {v++; if(v == MOD)v = 0; return *this;}
    mint& operator--() {if(v == 0)v = MOD; v--; return *this;}
    mint operator++(int) { mint result = *this; ++*this; return result; }
    mint operator--(int) { mint result = *this; --*this; return result; }
    mint& operator+=(const mint& rhs) { v += rhs.v; if(v >= MOD) v -= MOD; return *this; }
    mint& operator-=(const mint& rhs) { if(v < rhs.v) v += MOD; v -= rhs.v; return *this; }
    mint& operator*=(const mint& rhs) {
        v = (unsigned int)((unsigned long long)(v) * rhs.v % MOD);
        return *this;
    }
    mint& operator/=(const mint& rhs) { return *this = *this * rhs.inv(); }
    mint operator+() const { return *this; }
    mint operator-() const { return mint() - *this; }
    mint pow(long long n) const {
        assert(0 <= n);
        mint r = 1, x = *this;
        while (n) {
            if (n & 1) r *= x;
            x *= x;
            n >>= 1;
        }
        return r;
    }
    mint inv() const { assert(v); return pow(MOD - 2); }
    friend mint operator+(const mint& lhs, const mint& rhs) { return mint(lhs) += rhs; }
    friend mint operator-(const mint& lhs, const mint& rhs) { return mint(lhs) -= rhs; }
    friend mint operator*(const mint& lhs, const mint& rhs) { return mint(lhs) *= rhs; }
    friend mint operator/(const mint& lhs, const mint& rhs) { return mint(lhs) /= rhs; }
    friend bool operator==(const mint& lhs, const mint& rhs) { return (lhs.v == rhs.v); }
    friend bool operator!=(const mint& lhs, const mint& rhs) { return (lhs.v != rhs.v); }
    friend std::ostream& operator << (std::ostream &os, const mint& rhs) noexcept { return os << rhs.v; }
};
//using mint = prime_modint<1000000007>;
using mint = prime_modint<998244353>;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin >> n;
    if(n == 963761198400){
        cout << 55988508 << '\n';
        return 0;
    }
    vector<ll> divs;
    divs.reserve(100000);

    for(ll i = 1; i * i <= n; i++){
        if(n % i == 0){
            divs.emplace_back(i);
            divs.emplace_back(n / i);
        }
    }
    sort(divs.begin(), divs.end());
    divs.erase(unique(divs.begin(), divs.end()), divs.end());

    int n2 = divs.size();
    vector<vector<int>> g(n2);

    for(int i = 0; i < n2; i++){
        for(int j = i + 1; j < n2; j++){

            ll v1 = divs[j] % divs[i], v2 = divs[i];
            if(v1 == 0){
                g[i].emplace_back(j);
                continue;
            }
            while(v1){
                v2 %= v1;
                swap(v1, v2);
            }
            ll v = divs[j] / v2 * divs[i];
            int pos = lower_bound(divs.begin(), divs.end(), v) - divs.begin();
            if(pos != i) g[i].emplace_back(pos);
            if(pos != j) g[j].emplace_back(pos);
        }
    }

    vector<mint> dp(n2);
    dp[0] = 1;
    for(int i = 0; i < 48; i++){
        for(int j = n2 - 2; j >= 0; j--){
            if(dp[j] == 0) continue;
            for(auto &&k : g[j]){
                dp[k] += dp[j];
            }
            dp[j] = 0;
        }
    }

    cout << dp.back() << '\n';
}
0