Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ll binaryexponentiation(ll x, ll y, ll m){
- assert(y>=0);
- ll res=1;
- x%=m;
- while (y>0){
- if (y%2==1) res=res*x%m;
- x=x*x%m;
- y/=2;
- }
- return res;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement