PyRival
PyRival copied to clipboard
Template for modulo operations
One of the most common codes that I've looked up over time is a mod template that I wrote many years ago for a private repository. It is useful enough to be used around once every second competition.
I cleaned up my old code, and added some extra features to it. I think this could be a super useful template to have on PyRival!
Note that I have yet to add tests to it, I will do that tomorrow.
@cheran-senthil What do you think about this template? I think it is both very simple and super useful to have.
As a small note on the fast mod mul. Locally on my windows computer using PyPy the code runs around a factor of 10 faster with modmul compared to doing a * b % MOD
.
With the new version of PyPy on Windows, what are your thoughts on this moving forward?
With the new version of PyPy on Windows, what are your thoughts on this moving forward?
Once CF updates (assuming it ever updates) then we can remove all the fast modmul stuff from the template. But I still think this template has its uses even after that.