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

MODULO with 10^9+7

$
0
0

Is (a - b) mod m same as ((a mod m) - (b mod m)) mod m?I'm having hard time dealing with it.Also if (a mod m) < (b mod m) then answer should be ((a mod m) - (b mod m) + m) mod m? I tried using library function fmodl but it also giving negative answers.Also if I use unsigned numbers then output is something different.

So what is the correct way to calculate (a-b) mod m where a>=b>=m in C++.


Viewing all articles
Browse latest Browse all 40121

Trending Articles



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