[closed] Why getting wrong answer (CODEFT11)

The only difference is in line no 109 .
can u give me the reason please …!!!

AC
WA

@l_returns can u help plz …!!!

1 Like

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). :slightly_smiling_face:

2 Likes

ohh …!!!
Thanx @ souradeep1999