Here given an integer n, find positive integers a and b such that a+b=n
and LCM(a,b) is the minimum value possible.
Each test contains multiple test cases. The first line contains the number of test cases t (1≤t≤10).
Each test case consists of a single integer n (2≤n≤10^9).
For each test case, output two positive integers a and b, such that a+b=n and LCM(a,b) is the minimum possible.
For the first test case, the numbers we can choose are 1,3 or 2,2. LCM(1,3)=3 and LCM(2,2)=2, so we output 2 2.
For the second test case, the numbers we can choose are 1,5, 2,4, or 3,3. LCM(1,5)=5, LCM(2,4)=4, and LCM(3,3)=3, so we output 3 3.
For the third test case, LCM(3,6)=6.
It can be shown that there are no other pairs of numbers which sum to 9 that have a lower LCM.
Here is my code:
import math def lcm(a, b): return abs(a*b) // math.gcd(a, b) for x in range(int(input())): c =  a = int(input()) for i in range(a//2): c.append([lcm(i+1,a-(i+1)),i+1,a-(i+1)]) print(min(c),end=" ") print(min(c))
But my code is time limit Time limit exceeded on pretest 4 .How can i make my code more efficient ?
I try to solve this problem from codeforces.You can take a look of original problem from here.