Submission #22289629
Source Code Expand
def cmb(n, r, p):
if (r < 0) or (n < r):
return 0
r = min(r, n - r)
return fact[n] * factinv[r] * factinv[n-r] % p
p = 10 ** 9 + 7
N = 10 ** 6 # N は必要分だけ用意する
fact = [1, 1] # fact[n] = (n! mod p)
factinv = [1, 1] # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1] # factinv 計算用
for i in range(2, N + 1):
fact.append((fact[-1] * i) % p)
inv.append((-inv[p % i] * (p // i)) % p)
factinv.append((factinv[-1] * inv[-1]) % p)
#重複組み合わせ
mod = 10**9+7
N,K = map(int, input().split())
for k in range(1,K+1):
print(cmb(N-K+1, k, p)*cmb(K-1, k-1, p)%mod)
Submission Info
| Submission Time | |
|---|---|
| Task | D - Blue and Red Balls |
| User | H20 |
| Language | PyPy3 (7.3.0) |
| Score | 400 |
| Code Size | 643 Byte |
| Status | AC |
| Exec Time | 291 ms |
| Memory | 167900 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 400 / 400 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 01.txt, 02.txt |
| All | 01.txt, 02.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 01.txt | AC | 289 ms | 167800 KiB |
| 02.txt | AC | 267 ms | 167700 KiB |
| 11.txt | AC | 270 ms | 167688 KiB |
| 12.txt | AC | 264 ms | 167692 KiB |
| 13.txt | AC | 271 ms | 167588 KiB |
| 14.txt | AC | 273 ms | 167848 KiB |
| 15.txt | AC | 277 ms | 167732 KiB |
| 20.txt | AC | 272 ms | 167576 KiB |
| 21.txt | AC | 288 ms | 167900 KiB |
| 22.txt | AC | 291 ms | 167868 KiB |
| 23.txt | AC | 286 ms | 167804 KiB |
| 24.txt | AC | 270 ms | 167580 KiB |
| 25.txt | AC | 283 ms | 167664 KiB |
| 26.txt | AC | 288 ms | 167836 KiB |