We already know Basic Euclidean Algorithm. Now using Extended Euclidean Algorithm, Calculate the GCD and integer coefficients x, y using the same. x and y must satisfy the equation ax + by = gcd(a, b)
The first line of input contains integer T denoting the numer of testcases.T testcases follow. Each testcase contains one line on input containing two numbers a and b.
For each testcase, in a new line, print the GCD g for a, b, integer coefficients x, y calculated using Extended Euclidean Algorithm.
1 <= T <= 103
1 <= a, b <= 106
5 1 -2
If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.