結果

問題 No.2798 Multiple Chain
ユーザー aditya jain
提出日時 2024-06-28 22:22:33
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
RE  
実行時間 -
コード長 1,530 bytes
コンパイル時間 2,999 ms
コンパイル使用メモリ 255,796 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-28 22:22:45
合計ジャッジ時間 5,245 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 RE * 1
other AC * 32 WA * 12 RE * 7
権限があれば一括ダウンロードができます

ソースコード

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*p*p<=n;p++){
        if(p % 6 != 1 && p % 6 != 5 && p != 2 && p != 3) continue;
        ll e = 0;
        while(n % p == 0){
            n /= p;
            ++e;
        }
        if(e > 0) pf.emplace_back(e);
    }
    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);

    sort(pf.begin(), pf.end(), greater<int>());

    int maxL = pf[0];
    vector<vector<int>> dp(maxL + 1, vector<int>(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