Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 39796

What is (a.b)mod c?

$
0
0

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?


Viewing all articles
Browse latest Browse all 39796

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>