Error
|
|
---|---|
@Ibrahim Nash | 5761 |
@blackshadows | 5701 |
@akhayrutdinov | 5111 |
@mb1973 | 4989 |
@Quandray | 4944 |
@saiujwal13083 | 4506 |
@sanjay05 | 3762 |
@marius_valentin_dragoi | 3516 |
@sushant_a | 3459 |
@verma_ji | 3341 |
@KshamaGupta | 3318 |
Complete Leaderboard | |
|
|
@aroranayan999 | 938 |
@bt8816103042 | 739 |
@SHOAIBVIJAPURE | 428 |
@codeantik | 412 |
@SherlockHolmes3 | 407 |
@neverevergiveup | 348 |
@mahlawatep | 347 |
@shalinibhataniya1097 | 343 |
@murarry3625 | 333 |
@saiujwal13083 | 326 |
@rohitanand | 314 |
Complete Leaderboard |
Given two values ‘a’ and ‘b’ that represent coefficients in “ax – by = 0”, find the smallest values of x and y that satisfy the equation. It may also be assumed that x > 0, y > 0, a > 0 and b > 0.
Example 1:
Input: a = 25, b = 35
Output: 7 5
Explaination: 25*7 - 35*5 = 0. And x = 7
and y = 5 are the least possible values
of x and y to get the equation solved.
Example 2:
Input: a = 3, b = 7
Output: 7 3
Explaination: For this case x = 7 and
y = 3 are the least values of x and y
to satisfy the equation.
Your Task:
You do not need to read input or print anything. Your task is to complete the function findXY() which takes a and b as input parameters and returns the least possible values of x and y to satisfy the equation.
Expected Time Complexity: O(log(max(a, b)))
Expected Auxiliary Space: O(1)
Constraints:
1 ≤ a, b ≤ 104
We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?
Yes