Solve the Modular Multiplicative Inverse problem.
Input Specification
Line 1: (, is coprime to )
Note: The values will not fit in a 32 bit integer. They will fit in a 64 bit unsigned integer. For languages that do not have unsigned data types, please use a general big integer.
Output Specification
Line 1: The modular multiplicative inverse of modulo . The value should be nonnegative.
Sample Input
2 7
Sample Output
4
Comments
Is there anyway to disable the modinverse bigintger java function? This problem is not worth 7 points in java
Is this problem solvable using Fermat's Little Theorem?
I've implemented a variation of XGCD that does not give a coefficient on M, but am having issues with test case #15 and #22. All the rest are AC. Please help.
Try using unsigned long long
If you're still WAing, try signed 128-bit integers (__int128 in C++).
Isn't this problem really easy in Java? Java has a built in function for this, which is slow, but still passes.