Given a rectangle of dimensions L x B find the minimum number (N) of identical squares of maximum side that can be cut out from that rectangle so that no residue remains in the rectangle. Also find the dimension K of that square.
Example 1:
Input: L = 2, B = 4
Output: N = 2, K = 2
Explaination: 2 squares of 2x2 dimension.
Example 2:
Input: L = 6, B = 3
Output: N = 2, K = 3
Explaintion: 2 squares of 3x3 dimension. 
Your Task:
You do not need to read input or print anything. Your task is to complete the function minimumSquares() which takes L and B as input parameters and returns a list of 2 integers containing the values of N and K respectively.
Expected Time Complexity: O(log min(L, B))
Expected Auxiliary Space: O(1)
Constraints:
1 ≤ L, B ≤ 10^{9}

Difficulty: EASY
Tags: Combinatorics

Mathematics
Expected Time Complexity: O(log min(L, B))
Expected Auxiliary Space: O(1)

Starter code:
#User function Template for python3



class Solution:

    def minimumSquares(self, L, B):

        # code here

Solutions:
import math

class Solution:

	def minimumSquares(self, L, B):
		a = math.gcd(L, B)
		return (L * B // (a * a), a)


import math

class Solution:

	def minimumSquares(self, L, B):
		gcd = math.gcd(L, B)
		k = gcd
		n = L * B // (k * k)
		return (n, k)


def gcd(a, b):
	if b > a:
		(a, b) = (b, a)
	if b == 0:
		return a
	return gcd(a % b, b)

class Solution:

	def minimumSquares(self, L, B):
		l = L
		b = B
		ans = 0
		mx = max(l, b)
		mn = min(l, b)
		if mx % mn == 0:
			return [mx // mn, mn]
		else:
			g = gcd(mx, mn)
			return [mx * mn // (g * g), g]


class Solution:

	def minimumSquares(self, l, b):

		def gcd(l, b):
			if b == 0:
				return l
			return gcd(b, l % b)
		i = gcd(l, b)
		return [l // i * b // i, i]


class Solution:

	def minimumSquares(self, L, B):
		li = []
		l = L
		b = B
		while b:
			(l, b) = (b, l % b)
		li.append(int(L * B / l ** 2))
		li.append(l)
		return li


class Solution:

	def minimumSquares(self, L, B):
		temp = min(L, B)
		temp1 = max(L, B)

		def gcd(small, big):
			if big % small == 0:
				return small
			else:
				return gcd(big % small, small)
		var = gcd(temp, temp1)
		ans = L * B // (var * var)
		return (ans, var)


import math

class Solution:

	def minimumSquares(self, L, B):
		arr = []
		mini = min(L, B)
		for i in range(1, math.floor(math.sqrt(mini)) + 1):
			if mini % i == 0:
				arr.append(i)
				if mini // i != i:
					arr.append(mini // i)
		n = L * B
		k = 1
		for e in arr:
			if L * B % e ** 2 == 0 and L % e == 0 and (B % e == 0):
				temp = L * B // e ** 2
				if temp < n:
					n = temp
					k = e
		return (n, k)


class Solution:

	def minimumSquares(self, L, B):

		def hcf(L, B):
			if B > L:
				(L, B) = (B, L)
			while B:
				(L, B) = (B, L % B)
			return L
		k = hcf(L, B)
		n = L * B // (k * k)
		return (n, k)


class Solution:

	def minimumSquares(self, l, b):

		def hcf(num1, num2):
			return num2 if num1 == 0 else hcf(num2 % num1, num1)
		area = l * b
		k = hcf(l, b)
		sqarea = k * k
		n = int(area / sqarea)
		return (n, k)


class Solution:

	def computeGCD(self, x, y):
		while y:
			(x, y) = (y, x % y)
		return abs(x)

	def minimumSquares(self, L, B):
		k = self.computeGCD(L, B)
		n = L * B // (k * k)
		return (n, k)


import math

class Solution:

	def minimumSquares(self, max, min):
		res = []
		k = math.gcd(max, min)
		n = max * min // (k * k)
		return [n, k]


class Solution:

	def minimumSquares(self, L, B):
		m = self.gcd1(L, B)
		return [L * B // (m * m), m]

	def gcd1(self, a, b):
		if a == 0 or b == 0:
			return max(a, b)
		else:
			if a < b:
				return self.gcd1(a, b % a)
			return self.gcd1(a % b, b)


import math

class Solution:

	def minimumSquares(self, L, B):
		K = math.gcd(L, B)
		return (L * B // (K * K), K)


class Solution:

	def minimumSquares(self, L, B):

		def hcf(x, y):
			while y:
				(x, y) = (y, x % y)
			return x
		temp = hcf(L, B)
		return [max(L, B) // temp * min(L, B) // temp, temp] if temp != 1 else [L * B, 1]


class Solution:

	def minimumSquares(self, L, B):
		A = L * B
		while L % B != 0 and B % L != 0:
			if B < L:
				L = L % B
			elif B > L:
				B = B % L
			else:
				break
		K = min(L, B)
		N = A // (K * K)
		return (N, K)


def gcd(n, m):
	if n < m:
		(n, m) = (m, n)
	if n % m == 0:
		return m
	while m > 0:
		n = n % m
		(n, m) = (m, n)
	return n

class Solution:

	def minimumSquares(self, L, B):
		(a, b) = (L, B)
		x = gcd(a, b)
		y = a * b
		y = y // (x * x)
		return [y, x]


class Solution:

	def minimumSquares(self, L, B):
		x = min(L, B)
		y = max(L, B)
		(N, K) = (0, 0)
		if y % x == 0:
			K = x
			N = y // x
			return [N, K]
		else:
			a = x
			b = y
			while b:
				(a, b) = (b, a % b)
			hcf = a
			return [x * y // (hcf * hcf), hcf]
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		(L, B) = [int(x) for x in input().split()]
		ob = Solution()
		(N, K) = ob.minimumSquares(L, B)
		print(N, end=' ')
		print(K)


import math

class Solution:

	def minimumSquares(self, L, B):
		x = math.gcd(L, B)
		return [L * B // (x * x), x]


import math

class Solution:

	def minimumSquares(self, L, B):
		least = math.gcd(L, B)
		return [int(L * B / (least * least)), least]


class Solution:

	def minimumSquares(self, L, B):

		def hcf(x, y):
			while y:
				(x, y) = (y, x % y)
			return x
		k = hcf(L, B)
		n = L * B // (k * k)
		return (n, k)


class Solution:

	def gcd(self, a, b):
		if a % b == 0:
			return b
		return self.gcd(b, a % b)

	def minimumSquares(self, L, B):
		g = self.gcd(min(L, B), max(L, B))
		return (int(L * B / (g * g)), g)


class Solution:

	def gcd(self, a, b):
		if a < b:
			(a, b) = (b, a)
		if a % b == 0:
			return b
		return self.gcd(b, a % b)

	def minimumSquares(self, L, B):
		return (L * B // self.gcd(L, B) ** 2, self.gcd(L, B))


class Solution:

	def gcd(self, a, b):
		if a < b:
			(a, b) = (b, a)
		if a % b == 0:
			return b
		return self.gcd(b, a % b)

	def minimumSquares(self, L, B):
		t = min(L, B)
		k = L * B / t ** 2
		if k == int(k):
			return (int(k), t)
		else:
			return (L * B // self.gcd(L, B) ** 2, self.gcd(L, B))


class Solution:

	def gcd(self, a, b):
		if b == 0:
			return a
		return self.gcd(b, a % b)

	def minimumSquares(self, L, B):
		ans1 = self.gcd(L, B)
		ans2 = L * B // (ans1 * ans1)
		return (ans2, ans1)


import math

class Solution:

	def minimumSquares(self, L, B):
		sq_side = math.gcd(L, B)
		return (L * B // (sq_side * sq_side), sq_side)


class Solution:

	def gcd(a, b):
		if b == 0:
			return a
		return Solution.gcd(b, a % b)

	def minimumSquares(self, L, B):
		k = Solution.gcd(L, B)
		r = 0
		r = L * B // (k * k)
		return [r, k]


class Solution:

	def minimumSquares(self, L, B):
		a = L
		b = B
		while a > 0:
			(b, a) = (a, b % a)
		return (L // b * B // b, b)


import math

class Solution:

	def minimumSquares(self, l, b):
		g = math.gcd(l, b)
		ans = 0
		a = []
		while True:
			if l * b % g * g == 0:
				ans = l * b // (g * g)
				a = [ans, g]
				break
			g -= 1
		return a


class Solution:

	def minimumSquares(self, L, B):

		def gcd(L, B):
			if B == 0:
				return L
			return gcd(B, L % B)
		K = gcd(L, B)
		n = L * B // (K * K)
		return (n, K)


class Solution:

	def gcd(self, L1, B1):
		A = L1
		B = B1
		T = 1
		while B != 0:
			T = A % B
			A = B
			B = T
		return A

	def minimumSquares(self, L, B):
		K = self.gcd(L, B)
		N = int(L / K * B / K)
		return (N, K)


class Solution:

	def compute_hcf(self, x, y):
		while y:
			(x, y) = (y, x % y)
		return x

	def minimumSquares(self, L, B):
		N = 0
		K = 0
		if L > B:
			if L % B == 0:
				N = int(L / B)
				K = B
			else:
				hcf = self.compute_hcf(L, B)
				N = int(L * B / (hcf * hcf))
				K = hcf
		elif B % L == 0:
			N = int(B / L)
			K = L
		else:
			hcf = self.compute_hcf(L, B)
			N = int(L * B / (hcf * hcf))
			K = hcf
		return (N, K)


class Solution:

	def minimumSquares(self, L, B):

		def GCD(L, B):
			if B == 0:
				return L
			else:
				return GCD(B, L % B)
		k = GCD(L, B)
		n = int(L * B / (k * k))
		return (n, k)