• + 0 comments

    Python math.comb is so fast that the following brute-force one-liner works:

    def solve(n):
        return [math.comb(n, i)%10**9 for i in range(n+1)]
    

    You can watch Raymond Hettinger's amazing talk "Numerical Marvels Inside Python" to understand why math.comb is so fast, including with very very large n (group theory ahead!).