The only difference is in line no 109 .
can u give me the reason please …!!!
In WA soln: let’s assume (fac[n]%mod) = 1e9, (inverse[n-r]%mod) = 1e9, (inverse[r]%mod) = 1e9 and multiply of them near 1e27 and you didn’t use mod in between them, so int (long long) overfolow
1 Like
This is an example of incorrect assumption of operator precedence in C++. This is how the code snippet actually works:
val =
(
(
(
(
(
fac[n] % mod
) * inverse[n - r]
) % mod
) * inverse[r]
) % mod
) % mod;
Here is the code with the upper snippet in action (in lines 109
- 120
).
2 Likes