Submit solution

Points:
7

Time limit:
1.0s

Memory limit:
256M

Author:

Problem type

Allowed languages

Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, ~~CommonLisp~~, D, Dart, F#, Forth, Fortran, Go, ~~Groovy~~, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, ~~Nim~~, ~~ObjC~~, OCaml, ~~Octave~~, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

#### Problem Description

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 datatypes, 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

how can M be 0? edit: problem was fixed

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

Isn't this problem really easy in Java? Java has a built in function for this, which is slow, but still passes.