結果
| 問題 |
No.3047 Verification of Sorting Network
|
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 19:49:17 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 641 bytes |
| コンパイル時間 | 265 ms |
| コンパイル使用メモリ | 82,228 KB |
| 実行使用メモリ | 100,216 KB |
| 最終ジャッジ日時 | 2025-06-12 19:49:26 |
| 合計ジャッジ時間 | 9,000 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | RE * 3 |
| other | RE * 61 |
ソースコード
MOD = 10**9 + 7
max_a = 2 * 10**6 # Since M and N can be up to 1e6, a = M + N -1 can be up to 2e6 -1
# Precompute factorial and inverse factorial up to max_a
fact = [1] * (max_a + 1)
for i in range(1, max_a + 1):
fact[i] = fact[i-1] * i % MOD
inv_fact = [1] * (max_a + 1)
inv_fact[max_a] = pow(fact[max_a], MOD - 2, MOD)
for i in range(max_a - 1, -1, -1):
inv_fact[i] = inv_fact[i + 1] * (i + 1) % MOD
# Read input
N, M = map(int, input().split())
a = M + N - 1
if a < N:
comb_val = 0
else:
comb_val = fact[a] * inv_fact[N] % MOD
comb_val = comb_val * inv_fact[a - N] % MOD
ans = (2 * comb_val - M) % MOD
print(ans)
gew1fw