Sort by

recency

|

54 Discussions

|

  • + 1 comment

    As others have been saying, the answer numerically should be (m+n-2) choose (m-1) (mod 10^9 + 7). Of course, the problem is the time limit, which you will see if you try this method. Here are the two insights that I needed to solve this:

    1. since the answer is mod p, make your own factorial function that takes mod p for every successive multiplication
    2. Use FLT and fast exponentiation mod p to divide by (m-1)! and (n-1)! instead of calculating them and then dividing
  • + 0 comments

    Dive into the neon grid, dodging digital projectiles like a Moto X3M rider evading obstacles. Matrix Tracing: a mind-bending game of reflexes and precision. Each pulse of light tests your skill, demanding split-second decisions.

  • + 0 comments

    For those interested, the technique needed to solve this exercises is close to the implementation of math.comb in the Python standard library (albeit using modulo 2⁶⁴ which comes for free if using unsigned integers). You can watch Raymond Hettinger's keynote "Numerical Marvels Inside Python" for more explanations.

  • + 0 comments

    TLE'd on this but i was thinking somewhere along the lines of the followng: nc = int(math.factorial(m)//(math.factorial(r)*math.factorial(m-r))) where r in range(n)

  • + 0 comments

    My python3 solution but time limit execution

    def solve(n):
        if n == 0:
            return 1
        i = 5
        while True:
            if (n*"0") in str(math.factorial(i)):
                return i
            i += 1