結果

問題 No.1529 Constant Lcm
ユーザー yakkiyakki
提出日時 2021-06-04 21:08:33
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,942 bytes
コンパイル時間 1,455 ms
コンパイル使用メモリ 135,024 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-04-30 01:03:15
合計ジャッジ時間 6,048 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
10,624 KB
testcase_01 AC 3 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 TLE -
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<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
#include<numeric>
//#include<atcoder/all>
using namespace std;
//using namespace atcoder;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
//#define MOD 1000000007
#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592
#define PI acos(-1.0)

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;
//using mint = modint998244353;

int dh[] = {-1,0,1,0};
int dw[] = {0,1,0,-1};

vector<pair<ll,int>> factorize(ll n){
    vector<pair<ll,int>> div;
    ll d = n;
    for(ll i = 2; i*i <= n; i++){
        pair<ll,int> p;
        if(d % i == 0){
            p = make_pair(i,0);
            while(d % i == 0){
                d /= i;
                p.second++;
            }
            div.emplace_back(p);
        }
    }
    if(d != 1) div.emplace_back(d,1);
    return div;
}

ll modpow(ll a, ll n, ll m){
    if(n == 0) return 1;
    ll half = modpow(a,n/2,m);
    ll res = half * half % m;
    if(n & 1) res = res * (a%m) % m;
    return res;
}

int main(){
    int n; cin >> n;
    vector<int> cnt(n+1);
    ll ans = 1;
    for(int i = 1; i <= n-i; i++){
        auto div1 = factorize(i);
        auto div2 = factorize(n-i);
        map<int,int> cnt2;
        for(auto [u,v] : div1) cnt2[u] += v;
        for(auto [u,v] : div2) cnt2[u] += v;
        for(auto [u,v] : cnt2){
            if(cnt[u] < cnt2[u]){
                ans *= modpow(u,cnt2[u]-cnt[u],MOD);
                ans %= MOD;
                cnt[u] = cnt2[u];
            }
        }
        //cout << i << " " << ans << endl;
    }

    cout << ans << endl;
}


0