Can you please explain why you did

pwr(fact[x], mod - 2))%mod

?

Read more… (12 words)

Active In

Competitive Programming

Featured Contributions

reply in this discussion

reply in this discussion

**Lets try to come up with a recursion for the above DP state**. Assume w[i] > w

Is the following recursion correct?

best[i][w] = max(best[i-1][w], best[i-1][w-w[i]] + v[i])

The answer is YES but shouldn't it be NO since "w[i] > w" so we can't reduce it from w since it will lead to -ve total weight

Read more… (57 words)