結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
90,968 KB
testcase_01 AC 67 ms
90,880 KB
testcase_02 AC 69 ms
90,880 KB
testcase_03 AC 68 ms
91,104 KB
testcase_04 AC 69 ms
91,008 KB
testcase_05 AC 68 ms
90,800 KB
testcase_06 AC 74 ms
90,928 KB
testcase_07 AC 69 ms
90,852 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 69 ms
91,040 KB
testcase_12 AC 68 ms
90,936 KB
testcase_13 AC 69 ms
91,136 KB
testcase_14 AC 69 ms
90,676 KB
testcase_15 AC 72 ms
91,136 KB
testcase_16 AC 70 ms
90,744 KB
testcase_17 AC 67 ms
90,880 KB
testcase_18 AC 69 ms
90,796 KB
testcase_19 AC 69 ms
91,008 KB
testcase_20 AC 68 ms
90,868 KB
testcase_21 AC 68 ms
90,880 KB
testcase_22 AC 117 ms
91,128 KB
testcase_23 AC 69 ms
90,752 KB
testcase_24 AC 68 ms
91,008 KB
testcase_25 AC 69 ms
91,128 KB
testcase_26 AC 71 ms
90,880 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())
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