結果
| 問題 |
No.2023 Tiling is Fun
|
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-03-20 18:49:50 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 48 ms / 2,000 ms |
| コード長 | 723 bytes |
| コンパイル時間 | 152 ms |
| コンパイル使用メモリ | 82,972 KB |
| 実行使用メモリ | 62,576 KB |
| 最終ジャッジ日時 | 2025-03-20 18:52:09 |
| 合計ジャッジ時間 | 1,852 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 18 |
ソースコード
MOD = 998244353
def main():
a, b = map(int, input().split())
n = a + b - 2
k = a - 1
# Precompute factorial and inverse factorial up to required maximum
max_n = n # Since n is the maximum needed value
fact = [1] * (max_n + 1)
for i in range(1, max_n + 1):
fact[i] = fact[i-1] * i % MOD
inv_fact = [1] * (max_n + 1)
inv_fact[max_n] = pow(fact[max_n], MOD-2, MOD)
for i in range(max_n - 1, -1, -1):
inv_fact[i] = inv_fact[i+1] * (i+1) % MOD
# Compute combination(n, k)
if k < 0 or k > n:
print(0)
else:
ans = fact[n] * inv_fact[k] % MOD
ans = ans * inv_fact[n - k] % MOD
print(ans)
if __name__ == '__main__':
main()
lam6er