結果

問題 No.2141 Enumeratest
ユーザー 👑 tamatotamato
提出日時 2022-12-02 21:25:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 205 ms / 2,000 ms
コード長 931 bytes
コンパイル時間 176 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 108,928 KB
最終ジャッジ日時 2024-04-18 05:09:55
合計ジャッジ時間 7,367 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 151 ms
104,960 KB
testcase_01 AC 151 ms
104,704 KB
testcase_02 AC 176 ms
108,544 KB
testcase_03 AC 150 ms
104,576 KB
testcase_04 AC 166 ms
106,496 KB
testcase_05 AC 160 ms
106,496 KB
testcase_06 AC 160 ms
104,960 KB
testcase_07 AC 179 ms
105,728 KB
testcase_08 AC 160 ms
105,308 KB
testcase_09 AC 157 ms
105,344 KB
testcase_10 AC 147 ms
105,344 KB
testcase_11 AC 155 ms
105,856 KB
testcase_12 AC 166 ms
105,216 KB
testcase_13 AC 180 ms
104,960 KB
testcase_14 AC 157 ms
105,344 KB
testcase_15 AC 158 ms
104,832 KB
testcase_16 AC 185 ms
105,600 KB
testcase_17 AC 164 ms
107,904 KB
testcase_18 AC 164 ms
108,160 KB
testcase_19 AC 169 ms
108,160 KB
testcase_20 AC 167 ms
108,672 KB
testcase_21 AC 160 ms
108,416 KB
testcase_22 AC 172 ms
108,032 KB
testcase_23 AC 159 ms
108,288 KB
testcase_24 AC 169 ms
108,032 KB
testcase_25 AC 156 ms
108,928 KB
testcase_26 AC 166 ms
108,160 KB
testcase_27 AC 159 ms
108,288 KB
testcase_28 AC 171 ms
108,032 KB
testcase_29 AC 158 ms
108,524 KB
testcase_30 AC 205 ms
108,416 KB
testcase_31 AC 179 ms
107,776 KB
testcase_32 AC 173 ms
108,032 KB
testcase_33 AC 164 ms
108,288 KB
testcase_34 AC 166 ms
108,288 KB
testcase_35 AC 192 ms
108,160 KB
testcase_36 AC 162 ms
108,288 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 998244353


def main():
    import sys
    input = sys.stdin.readline

    # comb init
    nmax = 2 * 10 ** 6 + 10  # change here
    fac = [0] * nmax
    finv = [0] * nmax
    inv = [0] * nmax
    fac[0] = 1
    fac[1] = 1
    finv[0] = 1
    finv[1] = 1
    inv[1] = 1
    for i in range(2, nmax):
        fac[i] = fac[i - 1] * i % mod
        inv[i] = mod - inv[mod % i] * (mod // i) % mod
        finv[i] = finv[i - 1] * inv[i] % mod

    def comb(n, r):
        if n < r:
            return 0
        else:
            return (fac[n] * ((finv[r] * finv[n - r]) % mod)) % mod

    N, M = map(int, input().split())

    x = M // N
    num_large = M % N
    num_small = N - M % N
    ans = 1
    for _ in range(num_large):
        ans = (ans * comb(M, x+1)) % mod
        M -= x + 1
    for _ in range(num_small):
        ans = (ans * comb(M, x)) % mod
        M -= x
    print(ans)


if __name__ == '__main__':
    main()
0