結果

問題 No.2318 Phys Bone Maker
ユーザー 👑 tatyamtatyam
提出日時 2023-03-15 03:14:12
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,460 bytes
コンパイル時間 1,102 ms
コンパイル使用メモリ 100,780 KB
実行使用メモリ 8,736 KB
最終ジャッジ日時 2023-10-18 16:58:21
合計ジャッジ時間 5,644 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <cstdint>
#include <iostream>
#include <vector>
#include <atcoder/modint>
using namespace std;
using u64 = uint64_t;
using Modint = atcoder::modint998244353;


u64 binary_gcd(u64 x, u64 y) {
    if (!x or !y) return x + y;
    int n = __builtin_ctzll(x), m = __builtin_ctzll(y);
    x >>= n; y >>= m;
    while (x != y) {
        if (x > y) {
            x = (x - y) >> __builtin_ctzll(x - y);
        } else {
            y = (y - x) >> __builtin_ctzll(y - x);
        }
    }
    return x << (n > m ? m : n);
}
int main() {
    u64 N;
    cin >> N;
    
    auto divisor = [&]{
        vector<u64> divisor, divisor2;
        for(u64 d = 1; d * d <= N; d++) if(N % d == 0) {
            divisor.push_back(d);
            divisor2.push_back(N / d);
        }
        if(divisor.back() == divisor2.back()) divisor2.pop_back();
        divisor.insert(divisor.end(), divisor2.rbegin(), divisor2.rend());
        return divisor;
    }();
    
    auto press = [&](u64 x) {
        return lower_bound(divisor.begin(), divisor.end(), x) - divisor.begin();
    };
    
    vector<Modint> dp(divisor.size());
    dp[0] = 1;
    
    for(int i = 0; i < divisor.size(); i++) {
        const u64 A = divisor[i];
        for(u64 B : divisor) {
            const u64 GCD = binary_gcd(A, B);
            if(GCD == B) continue;
            const u64 LCM = A / GCD * B;
            dp[press(LCM)] += dp[i];
        }
    }
    
    cout << dp.back().val() << endl;
}
0