The problem was to find two numbers, and , such that their greatest common divisor and their least common multiple would add up to a given number, . Moreover, the difference between the two numbers should be as small as possible, and must be less than or equal to
problem description in codeforces
import math
def prime_factors(num):
ret = []
prime = 1
while num % 2 == 0:
prime *= 2
num = num / 2
prime > 1 and ret.append(2)
for i in range(3, int(math.sqrt(num)) + 1, 2):
prime = 1
while num % i == 0:
prime = prime * i
num = num / i
prime > 1 and ret.append(i//1)
if num > 2:
ret.append(num)
return ret
def find_ab(gcd,lcm):
"""
"""
return gcd,lcm
if __name__ == "__main__":
t = int(input()) #number of test case
while t:
x = int(input())
factors = prime_factors(x)
print(x)
print("===")
for n in factors:
gcd,lcm = n,x-n
print("----")
print(find_ab(gcd,lcm))
t-=1