A course consists of weeks, each of which has tasks. You pass the course, if you complete at least tasks each week.
How many ways can you pass the course so that you complete a total of tasks? Two ways of passing the course are considered different, if the lists of completed tasks in the order of completion are different.
You may assume that . The algorithm should be efficient in all these cases. The code must compute the results and not just return precomputed results.
In a file course.py
, implement a function count
that returns the number of ways to complete the course.
def count(x): # TODO if __name__ == "__main__": print(count(40)) # 78913132667888442497725132524762783866832203758436352000000000 print(count(55)) # 320424698352073967965876852452014215914220727801318938295395908593909760000000000000 print(count(64)) # 126886932185884164103433389335161480802865516174545192198801894375214704230400000000000000 print(count(100)) # 0
Explanation: When , exactly tasks must be completed each week. The tasks can be completed in different orders and the tasks for each week can be chosen in ways. Thus answer is . When , all tasks are completed and thus the answer is .