t=int(input())
while t > 0:
num=int(input())
lst=[]
n=0
for i in range(1,math.floor(math.sqrt(num))+1):
if num%i==0:
lst.append(i)
n=len(lst)
if n == 1:
print(1,num)
else:
print(lst[1],int(num/lst[1]))
t-=1
问题是在乘法中找到两个数字1 to num
成为num
(素数只有 1,num 和其余任何 2 个因数)。我现在看到的是超出时间限制的错误。谁能帮我优化它?