I am getting the wrong ans when using multiplicative modulo inverse,please tell the mistake!
Subarrays with distinct elements
Hello @ratik_puri,
Can you explain the following statement and the usage of power function:
long long sum=((a%mod)*((long long)power(2,mod-2)%mod))%mod;
The value that you are calculating as sum has the following formula:
sum=(len*(len+1))/2
Hope, this would help.
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.