Submission #70656894
Source Code Expand
mod = 998244353
n, m, s = map(lambda s_: int(s_), input().split())
nn = 10**6
fact = [1] * nn
for i in range(nn - 1):
fact[i + 1] = fact[i] * (i + 1) % mod
invfact = [1] * nn
invfact[nn - 1] = pow(fact[nn - 1], mod - 2, mod)
for i in range(nn - 1)[::-1]:
invfact[i] = invfact[i + 1] * (i + 1) % mod
def binom(x, y):
if x < 0 or y < 0 or x - y < 0:
return 0
return fact[x] * invfact[y] % mod * invfact[x - y] % mod
ans = 0
for i in range(n + 1):
d = s - i * (m + 1)
if d < 0:
break
b = binom(d + n - 1, n - 1)
ans += binom(n, i) * (-1)**i * b % mod
ans %= mod
print(ans)
Submission Info
| Submission Time | |
|---|---|
| Task | C - Sequence |
| User | wasd314 |
| Language | Python (PyPy 3.10-v7.3.12) |
| Score | 3 |
| Code Size | 651 Byte |
| Status | AC |
| Exec Time | 92 ms |
| Memory | 96996 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 3 / 3 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 00_sample_00.txt, 00_sample_01.txt |
| All | 00_sample_00.txt, 00_sample_01.txt, 01_random_00.txt, 01_random_01.txt, 02_m_small_00.txt, 02_m_small_01.txt, 02_m_small_02.txt, 03_max_00.txt, 04_min_00.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 00_sample_00.txt | AC | 79 ms | 96340 KiB |
| 00_sample_01.txt | AC | 80 ms | 96540 KiB |
| 01_random_00.txt | AC | 79 ms | 96556 KiB |
| 01_random_01.txt | AC | 80 ms | 96376 KiB |
| 02_m_small_00.txt | AC | 92 ms | 96796 KiB |
| 02_m_small_01.txt | AC | 88 ms | 96740 KiB |
| 02_m_small_02.txt | AC | 86 ms | 96996 KiB |
| 03_max_00.txt | AC | 79 ms | 96804 KiB |
| 04_min_00.txt | AC | 79 ms | 96432 KiB |