Equation Equals Hazards

Limits: 1s, 512 MB

You are given the equation, GCD(A,M) = 1. You have to determine whether there exists at least one integer X such that A*X mod M = 1.


This is a companion discussion topic for the original entry at https://toph.co/p/equation-equals-hazards