• + 5 comments

    The way modular arithmatic works, you can take the mod of each component of the product before you calculate the product and get the same result as if you were to mod the poduct after multiplying. My code had something like:

    int product = 1
    for (i<n-1) {
    product = product*T[i]%1234567
    }