結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 61 ms
90,992 KB
testcase_01 AC 63 ms
90,912 KB
testcase_02 AC 63 ms
90,816 KB
testcase_03 AC 64 ms
90,984 KB
testcase_04 AC 63 ms
90,608 KB
testcase_05 AC 60 ms
90,608 KB
testcase_06 AC 61 ms
90,616 KB
testcase_07 AC 63 ms
90,792 KB
testcase_08 AC 61 ms
90,856 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 62 ms
91,004 KB
testcase_12 AC 63 ms
90,620 KB
testcase_13 AC 63 ms
90,604 KB
testcase_14 AC 59 ms
90,812 KB
testcase_15 AC 62 ms
90,652 KB
testcase_16 AC 61 ms
90,744 KB
testcase_17 AC 61 ms
90,740 KB
testcase_18 AC 65 ms
90,800 KB
testcase_19 AC 62 ms
90,768 KB
testcase_20 AC 60 ms
90,880 KB
testcase_21 AC 58 ms
90,800 KB
testcase_22 AC 101 ms
91,184 KB
testcase_23 AC 61 ms
90,820 KB
testcase_24 AC 59 ms
90,860 KB
testcase_25 AC 60 ms
91,032 KB
testcase_26 AC 61 ms
90,732 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(m)
    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