結果

問題 No.1186 長方形の敷き詰め
ユーザー brthyyjpbrthyyjp
提出日時 2021-03-09 11:56:22
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 105 ms / 2,000 ms
コード長 572 bytes
コンパイル時間 289 ms
コンパイル使用メモリ 82,944 KB
実行使用メモリ 91,392 KB
最終ジャッジ日時 2024-04-19 10:10:22
合計ジャッジ時間 2,619 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
90,880 KB
testcase_01 AC 61 ms
90,876 KB
testcase_02 AC 62 ms
91,008 KB
testcase_03 AC 62 ms
90,672 KB
testcase_04 AC 62 ms
90,796 KB
testcase_05 AC 63 ms
90,736 KB
testcase_06 AC 60 ms
91,008 KB
testcase_07 AC 66 ms
90,728 KB
testcase_08 AC 63 ms
90,592 KB
testcase_09 AC 63 ms
91,200 KB
testcase_10 AC 64 ms
90,916 KB
testcase_11 AC 63 ms
90,892 KB
testcase_12 AC 64 ms
90,884 KB
testcase_13 AC 62 ms
90,792 KB
testcase_14 AC 64 ms
90,952 KB
testcase_15 AC 63 ms
91,140 KB
testcase_16 AC 64 ms
90,880 KB
testcase_17 AC 63 ms
90,728 KB
testcase_18 AC 62 ms
90,676 KB
testcase_19 AC 62 ms
90,892 KB
testcase_20 AC 61 ms
90,764 KB
testcase_21 AC 61 ms
90,824 KB
testcase_22 AC 105 ms
91,392 KB
testcase_23 AC 61 ms
91,032 KB
testcase_24 AC 63 ms
90,780 KB
testcase_25 AC 63 ms
90,864 KB
testcase_26 AC 63 ms
91,028 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = 10**6+50
mod = 998244353
fac = [1]*(N+1)
finv = [1]*(N+1)
for i in range(N):
    fac[i+1] = fac[i] * (i+1) % mod
finv[-1] = pow(fac[-1], mod-2, mod)
for i in reversed(range(N)):
    finv[i] = finv[i+1] * (i+1) % mod

def cmb1(n, r, mod):
    if r <0 or r > n:
        return 0
    r = min(r, n-r)
    return fac[n] * finv[r] * finv[n-r] % mod

n, m = map(int, input().split())

if m == 1:
    print(1)
    exit()

if n == 1:
    print(1)
    exit()

q, r = divmod(m, n)
ans = 0
for i in range(q+1):
    x = m-n*i
    ans += cmb1(x+i, i, mod)
    ans %= mod
print(ans)
0