結果

問題 No.2318 Phys Bone Maker
ユーザー milanis48663220milanis48663220
提出日時 2023-05-26 21:46:10
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 392 ms / 3,000 ms
コード長 2,964 bytes
コンパイル時間 2,728 ms
コンパイル使用メモリ 136,336 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-26 11:03:51
合計ジャッジ時間 6,431 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 392 ms
4,376 KB
testcase_03 AC 11 ms
4,380 KB
testcase_04 AC 15 ms
4,380 KB
testcase_05 AC 15 ms
4,380 KB
testcase_06 AC 14 ms
4,376 KB
testcase_07 AC 4 ms
4,376 KB
testcase_08 AC 14 ms
4,376 KB
testcase_09 AC 12 ms
4,376 KB
testcase_10 AC 23 ms
4,380 KB
testcase_11 AC 16 ms
4,380 KB
testcase_12 AC 23 ms
4,376 KB
testcase_13 AC 18 ms
4,380 KB
testcase_14 AC 16 ms
4,380 KB
testcase_15 AC 15 ms
4,376 KB
testcase_16 AC 15 ms
4,376 KB
testcase_17 AC 21 ms
4,376 KB
testcase_18 AC 22 ms
4,376 KB
testcase_19 AC 8 ms
4,376 KB
testcase_20 AC 17 ms
4,380 KB
testcase_21 AC 15 ms
4,380 KB
testcase_22 AC 12 ms
4,376 KB
testcase_23 AC 13 ms
4,376 KB
testcase_24 AC 20 ms
4,376 KB
testcase_25 AC 17 ms
4,376 KB
testcase_26 AC 17 ms
4,376 KB
testcase_27 AC 19 ms
4,380 KB
testcase_28 AC 12 ms
4,380 KB
testcase_29 AC 11 ms
4,380 KB
testcase_30 AC 9 ms
4,380 KB
testcase_31 AC 23 ms
4,376 KB
testcase_32 AC 19 ms
4,380 KB
testcase_33 AC 1 ms
4,376 KB
testcase_34 AC 18 ms
4,380 KB
testcase_35 AC 50 ms
4,376 KB
testcase_36 AC 193 ms
4,376 KB
testcase_37 AC 191 ms
4,376 KB
testcase_38 AC 198 ms
4,376 KB
testcase_39 AC 293 ms
4,380 KB
testcase_40 AC 289 ms
4,376 KB
testcase_41 AC 331 ms
4,376 KB
testcase_42 AC 331 ms
4,380 KB
testcase_43 AC 23 ms
4,380 KB
testcase_44 AC 56 ms
4,380 KB
testcase_45 AC 53 ms
4,380 KB
testcase_46 AC 335 ms
4,376 KB
testcase_47 AC 22 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cmath>
#include <numeric>
#include <functional>
#include <cassert>
#include <atcoder/modint>

#define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl;
#define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using namespace std;
typedef long long ll;

template<typename T>
vector<vector<T>> vec2d(int n, int m, T v){
    return vector<vector<T>>(n, vector<T>(m, v));
}

template<typename T>
vector<vector<vector<T>>> vec3d(int n, int m, int k, T v){
    return vector<vector<vector<T>>>(n, vector<vector<T>>(m, vector<T>(k, v)));
}

template<typename T>
void print_vector(vector<T> v, char delimiter=' '){
    if(v.empty()) {
        cout << endl;
        return;
    }
    for(int i = 0; i+1 < v.size(); i++) cout << v[i] << delimiter;
    cout << v.back() << endl;
}

using mint = atcoder::modint998244353;

ostream& operator<<(ostream& os, const mint& m){
    os << m.val();
    return os;
}

using P = pair<ll, int>; 

map<ll, int> factorize(ll n){
    ll m = n;
    map<ll, int> ans;
    for(ll p = 2; p*p <= n; p++){
        if(m%p != 0) continue;
        int cnt = 0;
        while(m%p == 0){
            cnt++;
            m /= p;
        }
        ans[p] = cnt;
    }
    if(m != 1) ans[m] = 1;
    return ans;
}

vector<ll> divs(ll n){
    vector<ll> ans;
    for(ll x = 1; x*x <= n; x++){
        if(n%x != 0) continue;
        ans.push_back(x);
        if(x*x != n) ans.push_back(n/x);
    }
    sort(ans.begin(), ans.end());
    return ans;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    ll n; cin >> n;
    auto v = divs(n);
    auto mp = factorize(n);
    vector<ll> p;
    for(auto [x, y]: mp) p.push_back(x);
    int m = v.size();
    auto c = vec2d(m, p.size(), 0);
    for(int i = 0; i < m; i++){
        ll cur = v[i];    
        for(int j = 0; j < p.size(); j++){
            while(cur%p[j] == 0){
                cur /= p[j];
                c[i][j]++;
            }
        }
    }
    vector<mint> dp(m);
    dp[0] = 1;
    for(int i = 0; i < m; i++){
        for(int j = 0; j < i; j++){
            if(v[i]%v[j] != 0){
                continue;
            }
            mint x = 1;
            for(int k = 0; k < p.size(); k++){
                if(c[i][k] == c[j][k]){
                    x *= c[i][k]+1;
                }
                // cout << c[i][k] << ' ' << c[j][k] << endl;

            }
            dp[i] += dp[j]*x;
            // cout << v[j] << "->" << v[i] << ' ' << x << endl;
        }
    }
    cout << dp.back() << endl;
}
0