結果

問題 No.2798 Multiple Chain
ユーザー aditya jainaditya jain
提出日時 2024-06-28 22:29:33
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 29 ms / 2,000 ms
コード長 1,576 bytes
コンパイル時間 3,420 ms
コンパイル使用メモリ 256,556 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-28 22:29:47
合計ジャッジ時間 6,135 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 24 ms
5,248 KB
testcase_01 AC 24 ms
5,376 KB
testcase_02 AC 24 ms
5,376 KB
testcase_03 AC 25 ms
5,376 KB
testcase_04 AC 24 ms
5,376 KB
testcase_05 AC 25 ms
5,376 KB
testcase_06 AC 25 ms
5,376 KB
testcase_07 AC 25 ms
5,376 KB
testcase_08 AC 24 ms
5,376 KB
testcase_09 AC 24 ms
5,376 KB
testcase_10 AC 24 ms
5,376 KB
testcase_11 AC 25 ms
5,376 KB
testcase_12 AC 24 ms
5,376 KB
testcase_13 AC 25 ms
5,376 KB
testcase_14 AC 25 ms
5,376 KB
testcase_15 AC 25 ms
5,376 KB
testcase_16 AC 24 ms
5,376 KB
testcase_17 AC 25 ms
5,376 KB
testcase_18 AC 24 ms
5,376 KB
testcase_19 AC 24 ms
5,376 KB
testcase_20 AC 25 ms
5,376 KB
testcase_21 AC 24 ms
5,376 KB
testcase_22 AC 25 ms
5,376 KB
testcase_23 AC 24 ms
5,376 KB
testcase_24 AC 24 ms
5,376 KB
testcase_25 AC 24 ms
5,376 KB
testcase_26 AC 25 ms
5,376 KB
testcase_27 AC 24 ms
5,376 KB
testcase_28 AC 24 ms
5,376 KB
testcase_29 AC 24 ms
5,376 KB
testcase_30 AC 29 ms
5,376 KB
testcase_31 AC 25 ms
5,376 KB
testcase_32 AC 25 ms
5,376 KB
testcase_33 AC 25 ms
5,376 KB
testcase_34 AC 24 ms
5,376 KB
testcase_35 AC 25 ms
5,376 KB
testcase_36 AC 25 ms
5,376 KB
testcase_37 AC 25 ms
5,376 KB
testcase_38 AC 25 ms
5,376 KB
testcase_39 AC 24 ms
5,376 KB
testcase_40 AC 25 ms
5,376 KB
testcase_41 AC 24 ms
5,376 KB
testcase_42 AC 24 ms
5,376 KB
testcase_43 AC 25 ms
5,376 KB
testcase_44 AC 24 ms
5,376 KB
testcase_45 AC 24 ms
5,376 KB
testcase_46 AC 25 ms
5,376 KB
testcase_47 AC 25 ms
5,376 KB
testcase_48 AC 24 ms
5,376 KB
testcase_49 AC 24 ms
5,376 KB
testcase_50 AC 25 ms
5,376 KB
testcase_51 AC 24 ms
5,376 KB
testcase_52 AC 24 ms
5,376 KB
testcase_53 AC 25 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
using namespace std;
using ll = long long int;
template<typename T>
ostream& operator+(ostream& out, const vector<T> &vec){
    for(const auto &x : vec){
        out<<x<<" ";
    }
    out<<"\n";
    return out;
}
template<typename T>
ostream& operator*(ostream& out, const vector<T> &vec){
    for(const auto &x : vec){
        out+x;
    }
    return out;
}
template<typename T>
istream& operator>>(istream& in, vector<T> &vec){
    for(auto &x : vec){
        in>>x;
    }
    return in;
}
void solve(){
    ll n;
    cin>>n;
    vector<int> pf;
    for(ll p=2;p<=2e6;p++){
        ll e = 0;
        while(n % p == 0){
            n /= p;
            ++e;
        }
        if(e > 0) pf.emplace_back(e);
    }
    
    if(n > 1){
        ll sq = sqrtl(n);
        if(sq * sq == n) pf.emplace_back(2);
        ++sq;
        if(sq * sq == n) pf.emplace_back(2);
        sq -= 2;
        if(sq * sq == n) pf.emplace_back(2);
    }

    if(pf.size() == 0){
        cout<<"1\n";
        return;
    }
    sort(pf.begin(), pf.end(), greater<int>());

    int maxL = pf[0];
    vector<vector<ll>> dp(maxL + 1, vector<ll>(maxL + 1));
    dp[0][0] = 1;
    for(int l=1;l<=maxL;l++){
        for(int s=0;s<=maxL;s++){
            for(int a=0;s-l*a>=0;a++){
                dp[l][s] += dp[l-1][s - l * a];
            }
        }
    }
    ll ans = 1;
    for(auto &e : pf){
        ans *= dp[maxL][e];
    }
    cout<<ans<<"\n";

}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
}
0