Where my code is wrong? its giving the wrong answer in some test cases
@abhi542136 while calculating cur you are taking individual mod of ans, (n-i) and inv but multiplying all these 3 together instead multiply in a pair of two and taking mod of result of that pair like this
ll cur = ( ( ans * (n-i) )%mod * inv )%mod;
no need to take individual mod as they are already modulated and less than 10^9+7.
1 Like
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.