結果

問題 No.1529 Constant Lcm
ユーザー tabae326tabae326
提出日時 2021-06-04 20:40:02
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 1,520 ms / 3,000 ms
コード長 1,674 bytes
コンパイル時間 2,637 ms
コンパイル使用メモリ 215,092 KB
実行使用メモリ 23,736 KB
最終ジャッジ日時 2023-08-12 09:56:46
合計ジャッジ時間 19,700 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
18,424 KB
testcase_01 AC 36 ms
18,592 KB
testcase_02 AC 34 ms
18,648 KB
testcase_03 AC 34 ms
18,728 KB
testcase_04 AC 33 ms
18,640 KB
testcase_05 AC 37 ms
18,460 KB
testcase_06 AC 32 ms
18,648 KB
testcase_07 AC 34 ms
18,648 KB
testcase_08 AC 36 ms
18,624 KB
testcase_09 AC 33 ms
18,484 KB
testcase_10 AC 1,333 ms
23,324 KB
testcase_11 AC 510 ms
20,464 KB
testcase_12 AC 53 ms
18,960 KB
testcase_13 AC 1,124 ms
22,504 KB
testcase_14 AC 691 ms
21,400 KB
testcase_15 AC 770 ms
21,612 KB
testcase_16 AC 602 ms
20,908 KB
testcase_17 AC 323 ms
19,924 KB
testcase_18 AC 350 ms
20,008 KB
testcase_19 AC 730 ms
21,368 KB
testcase_20 AC 1,506 ms
23,636 KB
testcase_21 AC 1,495 ms
23,364 KB
testcase_22 AC 1,488 ms
23,440 KB
testcase_23 AC 1,520 ms
23,736 KB
testcase_24 AC 1,493 ms
23,544 KB
testcase_25 AC 1,440 ms
23,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

struct osa_k {
    using _ll = long long;

    #define PRIME_FACTORIZE_MAX 2000010
    vector<_ll> primes;

    osa_k() {
        primes.resize((PRIME_FACTORIZE_MAX));
        for(_ll i = 0; i < PRIME_FACTORIZE_MAX; i++) {
            primes[i] = 1;
        }
        for(_ll i = 2; i < PRIME_FACTORIZE_MAX; i++) {
            if(primes[i] != 1) continue;
            for(_ll j = i; j <= PRIME_FACTORIZE_MAX; j += i) {
                primes[j] = i;
            }
        }
    }

    vector<pair<_ll,_ll>> factorize(_ll n){
        vector<pair<_ll,_ll>> res;
        while(n != 1) {
            _ll cur = primes[n];
            _ll cnt = 0;
            while(n % cur == 0) {
                n /= cur;
                cnt++;
            }
            res.push_back({cur, cnt});
        }
        reverse(res.begin(), res.end());
        return res;
    }
} osa_k;

vector<pair<long long, long long>>factorize(long long n) {
    return osa_k.factorize(n);
}

#include <atcoder/modint>
using mint = atcoder::modint998244353;

void solve() {
    ll n;
    cin >> n;
    map<ll,ll> mp;
    rep(i, 1, n) {
        auto u = factorize(i);
        auto v = factorize(n-i);
        map<ll,ll> w;
        for(auto [a, p] : u) w[a] += p;
        for(auto [a, p] : v) w[a] += p;
        for(auto [a, p] : w) mp[a] = max(mp[a], p);
    }    
    mint ans = 1;
    for(auto [a, p] : mp) ans *= mint(a).pow(p);
    cout << ans.val() << endl;
}

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