結果

問題 No.2141 Enumeratest
ユーザー terasaterasa
提出日時 2022-12-02 21:36:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 407 ms / 2,000 ms
コード長 1,791 bytes
コンパイル時間 281 ms
コンパイル使用メモリ 82,396 KB
実行使用メモリ 130,372 KB
最終ジャッジ日時 2024-04-18 05:23:35
合計ジャッジ時間 8,470 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
68,964 KB
testcase_01 AC 63 ms
68,644 KB
testcase_02 AC 144 ms
89,708 KB
testcase_03 AC 375 ms
130,372 KB
testcase_04 AC 407 ms
130,372 KB
testcase_05 AC 76 ms
70,500 KB
testcase_06 AC 63 ms
69,420 KB
testcase_07 AC 80 ms
75,652 KB
testcase_08 AC 161 ms
91,960 KB
testcase_09 AC 128 ms
89,088 KB
testcase_10 AC 214 ms
96,780 KB
testcase_11 AC 356 ms
128,052 KB
testcase_12 AC 71 ms
71,932 KB
testcase_13 AC 124 ms
88,608 KB
testcase_14 AC 357 ms
127,884 KB
testcase_15 AC 200 ms
95,860 KB
testcase_16 AC 283 ms
122,244 KB
testcase_17 AC 270 ms
120,660 KB
testcase_18 AC 158 ms
90,236 KB
testcase_19 AC 326 ms
124,672 KB
testcase_20 AC 187 ms
93,592 KB
testcase_21 AC 192 ms
93,716 KB
testcase_22 AC 150 ms
89,816 KB
testcase_23 AC 149 ms
89,600 KB
testcase_24 AC 382 ms
129,404 KB
testcase_25 AC 164 ms
91,312 KB
testcase_26 AC 88 ms
75,264 KB
testcase_27 AC 172 ms
91,940 KB
testcase_28 AC 162 ms
90,496 KB
testcase_29 AC 129 ms
88,064 KB
testcase_30 AC 309 ms
123,888 KB
testcase_31 AC 205 ms
94,776 KB
testcase_32 AC 307 ms
122,356 KB
testcase_33 AC 182 ms
92,936 KB
testcase_34 AC 323 ms
125,312 KB
testcase_35 AC 83 ms
76,352 KB
testcase_36 AC 174 ms
92,032 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from typing import List, Tuple, Callable, TypeVar
import sys
import itertools
import heapq
import bisect
import math
from collections import deque, defaultdict
from functools import lru_cache, cmp_to_key

input = sys.stdin.readline

if __file__ != 'prog.py':
    sys.setrecursionlimit(10 ** 6)


def readints(): return map(int, input().split())
def readlist(): return list(readints())
def readstr(): return input()[:-1]


class Combination:
    def __init__(self, N, mod):
        self.N = N
        self.mod = mod
        self.f = [None] * (N + 1)
        self.finv = [None] * (N + 1)
        self.inv = [None] * (N + 1)

        self.f[0] = 1
        self.f[1] = 1
        self.finv[0] = 1
        self.finv[1] = 1
        self.inv[1] = 1
        for i in range(2, N + 1):
            self.f[i] = self.f[i - 1] * i % self.mod
            self.inv[i] = self.mod - self.inv[self.mod % i] * (self.mod // i) % self.mod
            self.finv[i] = self.finv[i - 1] * self.inv[i] % self.mod

    def P(self, n, k):
        if n < k:
            return 0
        if n < 0 or k < 0:
            return 0
        return self.f[n] * self.finv[n - k] % self.mod

    def C(self, n, k):
        if n < k:
            return 0
        if n < 0 or k < 0:
            return 0
        return self.f[n] * (self.finv[k] * self.finv[n - k] % self.mod) % self.mod

    # 重複組合せ
    # n種類のものからk個選ぶ
    def H(self, n, k):
        if n == 0 and k == 0:
            return 1
        return self.C(k + n - 1, k)


N, M = readints()
mod = 998244353
comb = Combination(M, mod)
q, r = divmod(M, N)
ans = 1
rest = M
for i in range(r):
    ans *= comb.C(rest, q + 1)
    ans %= mod
    rest -= q + 1
for i in range(N - r):
    ans *= comb.C(rest, q)
    ans %= mod
    rest -= q
print(ans)
0