結果

問題 No.2798 Multiple Chain
ユーザー noya2
提出日時 2024-06-23 01:18:47
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 12 ms / 2,000 ms
コード長 1,042 bytes
コンパイル時間 3,116 ms
コンパイル使用メモリ 247,288 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-23 01:32:34
合計ジャッジ時間 3,815 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 51
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll = long long;

ll sqrt_floor(ll n) {
    if (n <= 0) return 0;
    ll x = sqrt(n);
    while ((x + 1) * (x + 1) <= n) x++;
    while (x * x > n) x--;
    return x;
}

int main(){
    const int mx = 61;
    vector<ll> partition_numbers(mx,0);
    partition_numbers[0] = 1;
    for (int n = 1; n < mx; n++){
        for (int k = 1; k*(3*k-1)/2 <= n; k++){
            partition_numbers[n] += partition_numbers[n-k*(3*k-1)/2] * (k % 2 == 0 ? -1 : 1);
        }
        for (int k = -1; k*(3*k-1)/2 <= n; k--){
            partition_numbers[n] += partition_numbers[n-k*(3*k-1)/2] * (k % 2 == 0 ? -1 : 1);
        }
    }
    ll n; cin >> n;
    ll ans = 1;
    for (ll d = 2; d*d*d <= n; d++){
        if (n % d != 0) continue;
        int e = 0;
        while (n % d == 0){
            n /= d;
            e++;
        }
        ans *= partition_numbers[e];
    }
    ll sq = sqrt_floor(n);
    if (n > 1 && sq * sq == n){
        ans *= partition_numbers[2];
    }
    cout << ans << endl;
}
0