結果

問題 No.1529 Constant Lcm
ユーザー tabae326tabae326
提出日時 2021-06-04 20:38:44
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 1,547 bytes
コンパイル時間 2,496 ms
コンパイル使用メモリ 215,608 KB
実行使用メモリ 817,136 KB
最終ジャッジ日時 2024-04-30 00:11:19
合計ジャッジ時間 6,170 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 47 ms
18,944 KB
testcase_01 AC 46 ms
18,816 KB
testcase_02 AC 44 ms
18,816 KB
testcase_03 AC 45 ms
18,816 KB
testcase_04 AC 50 ms
18,816 KB
testcase_05 AC 45 ms
18,944 KB
testcase_06 AC 45 ms
18,816 KB
testcase_07 AC 46 ms
18,816 KB
testcase_08 AC 46 ms
18,816 KB
testcase_09 AC 44 ms
18,816 KB
testcase_10 MLE -
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 -- -
権限があれば一括ダウンロードができます

ソースコード

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 * (n-i));
        for(auto [a, p] : u) 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