sir please tell me how to use modulo to keep answer in range
have i used it correctly or should i use like
a%mod +b%mod or (a+b)%mod
which is correct and what is the diiference .please Provide detailed explanation.
How to use modulo
Hi @D19APPPP0016,
u need to mod like
ans= ((a%MOD) + (b%MOD))%MOD
let a,b be 10 and mod=11 ;
so in the case we take only a%Mod + b%Mod, we will get wrong answer.
if u use mod like (a+b)%Mod, there is no problem but some times a+b might overflow 10^18.
so ans= ((a%MOD) + (b%MOD))%MOD
this is prefered.
Hope dis helps.