Submission #7680840
Source Code Expand
#!/usr/bin/env python3
import math
import sys
from functools import lru_cache
sys.setrecursionlimit(10 ** 7)
MOD = 1000000007 # type: int
@lru_cache(10000)
def combinations_count(n, r):
if n - r < 0:
return 0
return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def solve(N: int, K: int):
choices = N - K + 1
for i in range(K):
print(int(combinations_count(choices, i + 1) * combinations_count(K - 1, i)) % MOD)
return
# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools (tips: You use the default template now. You can remove this line by using your custom template)
def main():
def iterate_tokens():
for line in sys.stdin:
for word in line.split():
yield word
tokens = iterate_tokens()
N = int(next(tokens)) # type: int
K = int(next(tokens)) # type: int
solve(N, K)
if __name__ == '__main__':
main()
Submission Info
| Submission Time | |
|---|---|
| Task | D - Blue and Red Balls |
| User | showwin |
| Language | Python (3.4.3) |
| Score | 400 |
| Code Size | 946 Byte |
| Status | AC |
| Exec Time | 870 ms |
| Memory | 5780 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 | 23 ms | 3572 KiB |
| 02.txt | AC | 24 ms | 3572 KiB |
| 11.txt | AC | 25 ms | 3572 KiB |
| 12.txt | AC | 24 ms | 3572 KiB |
| 13.txt | AC | 24 ms | 3572 KiB |
| 14.txt | AC | 23 ms | 3572 KiB |
| 15.txt | AC | 23 ms | 3572 KiB |
| 20.txt | AC | 24 ms | 3572 KiB |
| 21.txt | AC | 328 ms | 4964 KiB |
| 22.txt | AC | 841 ms | 5660 KiB |
| 23.txt | AC | 870 ms | 5780 KiB |
| 24.txt | AC | 31 ms | 3572 KiB |
| 25.txt | AC | 223 ms | 4532 KiB |
| 26.txt | AC | 405 ms | 5236 KiB |