Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ll d, x, y;
- void extendedEuclid(ll A, ll B) {
- if(B == 0) {
- d = A;
- x = 1;
- y = 0;
- }
- else {
- extendedEuclid(B, A%B);
- ll temp = x;
- x = y;
- y = temp - (A/B)*y;
- }
- }
- ll modinv(ll a){
- extendedEuclid(a,m);
- return (x%m+m)%m;
- }
Add Comment
Please, Sign In to add comment