結果

問題 No.1186 長方形の敷き詰め
ユーザー tamatotamato
提出日時 2020-10-14 17:07:19
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 158 ms / 2,000 ms
コード長 890 bytes
コンパイル時間 289 ms
コンパイル使用メモリ 87,680 KB
実行使用メモリ 99,944 KB
最終ジャッジ日時 2023-09-28 00:40:24
合計ジャッジ時間 5,126 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
99,836 KB
testcase_01 AC 137 ms
99,540 KB
testcase_02 AC 125 ms
99,420 KB
testcase_03 AC 138 ms
99,504 KB
testcase_04 AC 123 ms
99,852 KB
testcase_05 AC 136 ms
99,528 KB
testcase_06 AC 121 ms
99,848 KB
testcase_07 AC 158 ms
99,460 KB
testcase_08 AC 117 ms
99,432 KB
testcase_09 AC 116 ms
99,844 KB
testcase_10 AC 115 ms
99,820 KB
testcase_11 AC 115 ms
99,628 KB
testcase_12 AC 114 ms
99,452 KB
testcase_13 AC 115 ms
99,676 KB
testcase_14 AC 119 ms
99,536 KB
testcase_15 AC 119 ms
99,416 KB
testcase_16 AC 120 ms
99,936 KB
testcase_17 AC 121 ms
99,944 KB
testcase_18 AC 118 ms
99,540 KB
testcase_19 AC 115 ms
99,528 KB
testcase_20 AC 114 ms
99,632 KB
testcase_21 AC 118 ms
99,576 KB
testcase_22 AC 127 ms
99,680 KB
testcase_23 AC 122 ms
99,624 KB
testcase_24 AC 122 ms
99,452 KB
testcase_25 AC 125 ms
99,576 KB
testcase_26 AC 118 ms
99,476 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 998244353
eps = 10**-9


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

    # comb init
    # mod = 1000000007
    nmax = 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())
    if N == 1:
        print(1)
        exit()
    ans = 0
    for K in range(M + 1):
        if M - N * K < 0:
            break
        ans = (ans + comb(M - N * K + K, K))%mod
    print(ans)


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