結果

問題 No.1186 長方形の敷き詰め
ユーザー boutarouboutarou
提出日時 2020-08-24 08:22:08
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 580 bytes
コンパイル時間 173 ms
コンパイル使用メモリ 82,292 KB
実行使用メモリ 97,848 KB
最終ジャッジ日時 2024-04-23 22:38:02
合計ジャッジ時間 3,725 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 89 ms
89,632 KB
testcase_01 AC 88 ms
89,616 KB
testcase_02 RE -
testcase_03 AC 85 ms
89,840 KB
testcase_04 AC 86 ms
89,344 KB
testcase_05 AC 85 ms
89,704 KB
testcase_06 WA -
testcase_07 AC 85 ms
89,908 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 86 ms
89,600 KB
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 AC 95 ms
91,628 KB
testcase_23 AC 87 ms
90,112 KB
testcase_24 AC 84 ms
89,784 KB
testcase_25 AC 83 ms
89,856 KB
testcase_26 AC 84 ms
89,892 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 998244353
MAX = 10 ** 6 * 2 + 10

fact = [0] * MAX
inv = [0] * MAX

fact[0] = 1
for i in range(1, MAX):
    fact[i] = fact[i - 1] * i % MOD

inv[MAX - 1] = pow(fact[MAX - 1], MOD - 2, MOD)
for i in range(MAX - 1, 0, -1):
    inv[i - 1] = inv[i] * i % MOD

def nPk(n, k):
    return fact[n] * inv[n - k] % MOD

def nCk(n, k):
    return nPk(n, k) * inv[k] % MOD

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

if (n > m):
    n, m = m, n

ans = 0

for i in range(0, m + 1, n):
    sikiri = i // n
    rest = m - sikiri * n
    ans += nCk(sikiri + rest, sikiri)
    ans %= MOD

print(ans)
0