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

How to calculate ((a1*a2*a3.....*an)/(b1*b2*b3*...bn))mod n

$
0
0

I came across a problem whose answer is in the form of ((a1 x a2 x a3.....x an)/(b1 x b2 x b3 x...bn))mod n.

All a and b are very large so actual multiplication and division are not possible.

I know (a x b)%m can be written as ((a%m)x(b%m))%m, but if I simplify using that and do A/B, I'm getting the wrong answer.

Please help me with this.

Update: Forgot to mention that the result of (a1 x a2 x a3.....x an)/(b1 x b2 x b3 x...bn) is always a whole number, i.e values of all B's get cancelled by some A's.


Viewing all articles
Browse latest Browse all 39796

Trending Articles



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