What I noticed is that 'long long int' can store only 9 digit numbers in the C/C++ compiler in codechef. So when I want to calculate, say
(a.b)mod c
and, 'a' and 'b' are quite large (say 10^9+5) and c=10^9+7, then (a.b) is pretty large and an overflow occurs. Therefore, when I try to do a 'mod c' of the result, a negative value appears.
So, how do I find (a.b)mod c in constant time?
↧
What is (a.b)mod c?
↧