Please subscribe to the official Codeforces channel in Telegram via the link ×

If mod(%) are so expensive why not make own modulus?

Revision en1, by Qualified, 2020-07-25 21:21:07

I see this article and at the bottom, it says that modulus operators are expensive so they implemented a slightly faster version of Euclidean Algorithm. Why not make a more efficient mod?

int mod(int a, int b) { // computes a % b;
	return (a - b * (a / b));


  Rev. Lang. By When Δ Comment
en1 English Qualified 2020-07-25 21:21:07 389 Initial revision (published)