2020-04-07 10:55:27 +00:00
|
|
|
function n(n){return(n=BigInt(n))>=0n?n:-n}function t(n){if(1n===(n=BigInt(n)))return 1;let t=1;do{t++}while((n>>=1n)>1n);return t}function r(n,t){if((n=BigInt(n))<=0n|(t=BigInt(t))<=0n)return NaN;let r=0n,i=1n,u=1n,e=0n;for(;0n!==n;){const f=t/n,o=t%n,g=r-u*f,B=i-e*f;t=n,n=o,r=u,i=e,u=g,e=B}return{b:t,x:r,y:i}}function i(t,r){if(t=n(t),r=n(r),0n===t)return r;if(0n===r)return t;let i=0n;for(;!(1n&(t|r));)t>>=1n,r>>=1n,i++;for(;!(1n&t);)t>>=1n;do{for(;!(1n&r);)r>>=1n;if(t>r){const n=t;t=r,r=n}r-=t}while(r);return t<<i}function u(t,r){return t=BigInt(t),r=BigInt(r),0n===t&&0n===r?0n:n(t*r)/i(t,r)}function e(n,t){return(n=BigInt(n))>=(t=BigInt(t))?n:t}function f(n,t){return(n=BigInt(n))>=(t=BigInt(t))?t:n}function o(n,t){const i=r(B(n,t),t);return 1n!==i.b?NaN:B(i.x,t)}function g(t,r,i){if(0n===(i=BigInt(i)))return NaN;if(1n===i)return 0n;if(t=B(t,i),(r=BigInt(r))<0n)return o(g(t,n(r),i),i);let u=1n;for(;r>0;)r%2n===1n&&(u=u*t%i),r/=2n,t=t**2n%i;return u}function B(n,t){return(t=BigInt(t))<=0?NaN:(n=BigInt(n)%t)<0?n+t:n}export{n as abs,t as bitLength,r as eGcd,i as gcd,u as lcm,e as max,f as min,o as modInv,g as modPow,B as toZn};
|