- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMODular Functions.cpp
More file actions
Latest commit
6 lines (6 loc) · 456 Bytes
/
Copy pathMODular Functions.cpp
File metadata and controls
6 lines (6 loc) · 456 Bytes
1
2
3
4
5
6
ll add(ll x, ll y) {ll res = x + y; return (res >= MOD ? res - MOD : res);}
ll mul(ll x, ll y) {ll res = x * y; return (res >= MOD ? res % MOD : res);}
ll sub(ll x, ll y) {ll res = x - y; return (res < 0 ? res + MOD : res);}
ll lcm(ll x, ll y) {ll res = (x * y) / __gcd(x, y); return res;}
ll power(ll x, ll y) {ll res = 1; x %= MOD; while (y) {if (y & 1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;}
ll mod_inv(ll x) {returnpower(x, MOD - 2);}