結果

問題 No.2798 Multiple Chain
ユーザー Akidai16
提出日時 2024-07-23 17:50:45
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 22 ms / 2,000 ms
コード長 1,802 bytes
コンパイル時間 4,230 ms
コンパイル使用メモリ 258,828 KB
最終ジャッジ日時 2025-02-23 17:54:09
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 51
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

#define REP(i, init, n) for(int i = (int)(init); i < (int)(n); i++)
#define RREP(i, init, n) for(int i = (int)(init); i >= (int)(n); i--)
#define All(A) A.begin(), A.end()
#define rAll(A) A.rbegin(), A.rend()

#define vi vector<int>
#define vl vector<long>
#define vvi vector<vector<int>>
#define vvl vector<vector<long>>
#define pint pair<int, int>
#define plong pair<long, long>

long N;

vector<plong> prime_factorization(long n) {
    vector<plong> res;
    long p = 2;
    while(n >= p * p && p <= 1000000) {
        int cnt = 0;
        while(n % p == 0) {
            cnt++;
            n /= p;
        }
        if(cnt != 0) res.push_back({p, cnt});
        p++;
    }
    if(n > 1) res.push_back({n, 1});
    return res;
}

bool is_square(long n) {
    long sq = sqrtl(n);
    return sq * sq == n;
}

void solve() {
    vector dp(61, vector(61, 0L));
    dp[0][0] = 1;
    REP(i, 1, 61) {
        REP(j, 1, 61) {
            dp[i][j] = dp[i - 1][j - 1];
            if(i - j >= 0) {
                dp[i][j] += dp[i - j][j];
            }
        }
    }

    vl cnt(61, 0);
    REP(i, 1, 61) {
        REP(j, 1, 61) {
            cnt[i] += dp[i][j];
        }
    }

    auto pf = prime_factorization(N);
    long ans = 1;
    for(auto p : pf) {
        if(p.first > 1000000000000L) {
            if(is_square(p.first)) {
                ans *= cnt[2];
            } else {
                ans *= cnt[1];
            }
            continue;
        }

        ans *= cnt[p.second];
    }
    cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    cin >> N;
    solve();
}
0