結果

問題 No.2318 Phys Bone Maker
ユーザー t98slidert98slider
提出日時 2023-05-27 00:11:28
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 359 ms / 3,000 ms
コード長 1,733 bytes
コンパイル時間 3,891 ms
コンパイル使用メモリ 234,808 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-26 14:17:03
合計ジャッジ時間 8,323 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 359 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 3 ms
4,380 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 3 ms
4,384 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 1 ms
4,380 KB
testcase_29 AC 1 ms
4,376 KB
testcase_30 AC 3 ms
4,376 KB
testcase_31 AC 2 ms
4,376 KB
testcase_32 AC 4 ms
4,380 KB
testcase_33 AC 2 ms
4,380 KB
testcase_34 AC 2 ms
4,376 KB
testcase_35 AC 39 ms
4,376 KB
testcase_36 AC 173 ms
4,376 KB
testcase_37 AC 173 ms
4,384 KB
testcase_38 AC 173 ms
4,384 KB
testcase_39 AC 264 ms
4,376 KB
testcase_40 AC 265 ms
4,376 KB
testcase_41 AC 300 ms
4,380 KB
testcase_42 AC 301 ms
4,376 KB
testcase_43 AC 2 ms
4,376 KB
testcase_44 AC 34 ms
4,380 KB
testcase_45 AC 32 ms
4,380 KB
testcase_46 AC 308 ms
4,376 KB
testcase_47 AC 7 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using ll = long long;
using mint = atcoder::modint998244353;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin >> n;
    vector<pair<ll, int>> p;
    if(n % 2 == 0){
        n /= 2;
        p.emplace_back(2, 1);
        while(n % 2 == 0){
            n /= 2;
            p.back().second++;
        }
    }
    for(ll i = 3; i * i <= n; i += 2){
        if(n % i == 0){
            n /= i;
            p.emplace_back(i, 1);
            while(n % i == 0){
                n /= i;
                p.back().second++;
            }
        }
    }
    if(n != 1) p.emplace_back(n, 1);
    vector<ll> divs(1, 1);
    int m = p.size();
    for(int i = 0; i < m; i++){
        int c = divs.size();
        ll d = 1;
        for(int j = 0; j < p[i].second; j++){
            d *= p[i].first;
            for(int k = 0; k < c; k++){
                divs.emplace_back(divs[k] * d);
            }
        }
    }
    sort(divs.begin(), divs.end());
    int n2 = divs.size();
    int cnt[n2][m] = {};
    for(int i = 0; i < n2; i++){
        ll v = divs[i];
        for(int j = 0; j < m; j++){
            while(v % p[j].first == 0){
                cnt[i][j]++;
                v /= p[j].first;
            }
        }
    }
    mint dp[n2];
    dp[0] = 1;
    for(int i = 0; i + 1 < n2; i++){
        for(int j = i + 1; j < n2; j++){
            if(divs[j] % divs[i] == 0){
                mint coef = 1;
                for(int k = 0; k < m; k++){
                    if(cnt[i][k] >= cnt[j][k]) coef *= cnt[i][k] + 1;
                }
                dp[j] += coef * dp[i];
            }
        }
    }
    cout << dp[n2 - 1].val() << '\n';
}
0