結果
問題 | No.1186 長方形の敷き詰め |
ユーザー |
![]() |
提出日時 | 2025-03-20 21:20:33 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 895 bytes |
コンパイル時間 | 217 ms |
コンパイル使用メモリ | 82,240 KB |
実行使用メモリ | 75,868 KB |
最終ジャッジ日時 | 2025-03-20 21:21:34 |
合計ジャッジ時間 | 2,277 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 WA * 3 |
ソースコード
MOD = 998244353def main():import sysinput = sys.stdin.read().split()N = int(input[0])M = int(input[1])max_fact = M # since n can be up to M when k=0# Precompute factorials and inverse factorials up to max_factfact = [1] * (max_fact + 1)for i in range(1, max_fact + 1):fact[i] = fact[i-1] * i % MODinv_fact = [1] * (max_fact + 1)inv_fact[max_fact] = pow(fact[max_fact], MOD-2, MOD)for i in range(max_fact - 1, -1, -1):inv_fact[i] = inv_fact[i+1] * (i+1) % MODK = M // Nans = 0for k in range(0, K + 1):n = M - k * (N - 1)# compute C(n, k)if k > n:comb = 0else:comb = fact[n] * inv_fact[k] % MODcomb = comb * inv_fact[n - k] % MODans = (ans + comb) % MODprint(ans)if __name__ == "__main__":main()