✔ 最佳答案
The two integers are co-prime - which means we can use the Extended Euclidean Algorithm.
By running the algorithm, we can see that
1007 x 115 + 1703 x (-68) = 1
So n = 115, m = -68.
2015-03-20 23:31:31 補充:
The Euclidean Algorithm is quite simple. It is basically,
Assuming a > b, then GCD(a, b) = GCD(a % b, b)
They will eventually divides, and that's the answer.
Two examples:
GCD(3, 7) = GCD(7, 3) = GCD(1, 3) = GCD(3, 1)
GCD(48, 36) = GCD(12, 36) = GCD(36, 12) = 12.
2015-03-20 23:35:41 補充:
With that, the extended version keep tracks of the coefficients.
Suppose we know gcd(a % b, b), m'(a%b) + n'(b), then
gcd(a, b) = gcd(a%b, b) = m'(a - kb) + n'b = m'a + (n'-m'k)b
For example, gcd(1, 3) = 1, 0 x 3 + 1 x 1 = 1
Then gcd(7,3) = gcd(1,3), 0 x 3 + (7 - 3 x 2) x 1 = 1, 7 - 3 x 2 = 1.
2015-03-24 00:49:39 補充:
Thanks for your comments
參考: Extended Euclidean Algorithm Calculator