結果

問題 No.2141 Enumeratest
ユーザー ぷらぷら
提出日時 2022-12-02 21:23:37
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 208 ms / 2,000 ms
コード長 1,176 bytes
コンパイル時間 2,145 ms
コンパイル使用メモリ 195,552 KB
実行使用メモリ 50,432 KB
最終ジャッジ日時 2024-04-18 05:07:17
合計ジャッジ時間 7,424 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 55 ms
50,304 KB
testcase_01 AC 54 ms
50,432 KB
testcase_02 AC 59 ms
50,304 KB
testcase_03 AC 101 ms
50,304 KB
testcase_04 AC 204 ms
50,324 KB
testcase_05 AC 208 ms
50,312 KB
testcase_06 AC 57 ms
50,384 KB
testcase_07 AC 60 ms
50,432 KB
testcase_08 AC 60 ms
50,432 KB
testcase_09 AC 65 ms
50,344 KB
testcase_10 AC 63 ms
50,156 KB
testcase_11 AC 64 ms
50,304 KB
testcase_12 AC 59 ms
50,432 KB
testcase_13 AC 62 ms
50,324 KB
testcase_14 AC 53 ms
50,432 KB
testcase_15 AC 62 ms
50,304 KB
testcase_16 AC 56 ms
50,304 KB
testcase_17 AC 151 ms
50,432 KB
testcase_18 AC 176 ms
50,432 KB
testcase_19 AC 191 ms
50,400 KB
testcase_20 AC 160 ms
50,304 KB
testcase_21 AC 173 ms
50,400 KB
testcase_22 AC 141 ms
50,304 KB
testcase_23 AC 93 ms
50,432 KB
testcase_24 AC 88 ms
50,304 KB
testcase_25 AC 63 ms
50,304 KB
testcase_26 AC 194 ms
50,312 KB
testcase_27 AC 171 ms
50,432 KB
testcase_28 AC 191 ms
50,304 KB
testcase_29 AC 131 ms
50,304 KB
testcase_30 AC 188 ms
50,300 KB
testcase_31 AC 149 ms
50,380 KB
testcase_32 AC 162 ms
50,304 KB
testcase_33 AC 142 ms
50,416 KB
testcase_34 AC 137 ms
50,304 KB
testcase_35 AC 63 ms
50,356 KB
testcase_36 AC 186 ms
50,304 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

constexpr int mod = 998244353;

long long fac[2000005], finv[2000005], inv[2000005];

void COMinit() {
    fac[0] = fac[1] = finv[0] = finv[1] = inv[1] = 1;
    for (int i = 2; i < 2000005; i++) {
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

long long choose(int n,int k) {
    if(n < 0 || k < 0) return 0;
    if(n == 0) return 1;
    return COM(n+k-1,k-1);
}

long long modpow(long long a,long long b) {
    long long ans = 1;
    while(b) {
        if(b & 1) {
            (ans *= a) %= mod;
        }
        (a *= a) %= mod;
        b /= 2;
    }
    return ans;
}

int main() {
    COMinit();
    int N,M;
    cin >> N >> M;
    int ans = fac[M];
    for(int i = 0; i < N; i++) {
        if(M%N > i) {
            ans = ans*modpow(fac[M/N+1],mod-2)%mod;
        }
        else {
            ans = ans*modpow(fac[M/N],mod-2)%mod;
        }
    }
    cout << ans << endl;
}
0