<p>Given an integer <code>num</code>, find the closest two integers in absolute difference whose product equals&nbsp;<code>num + 1</code>&nbsp;or <code>num + 2</code>.</p>

<p>Return the two integers in any order.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:</strong> num = 8
<strong>Output:</strong> [3,3]
<strong>Explanation:</strong> For num + 1 = 9, the closest divisors are 3 &amp; 3, for num + 2 = 10, the closest divisors are 2 &amp; 5, hence 3 &amp; 3 is chosen.
</pre>

<p><strong class="example">Example 2:</strong></p>

<pre>
<strong>Input:</strong> num = 123
<strong>Output:</strong> [5,25]
</pre>

<p><strong class="example">Example 3:</strong></p>

<pre>
<strong>Input:</strong> num = 999
<strong>Output:</strong> [40,25]
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>1 &lt;= num &lt;= 10^9</code></li>
</ul>

class Solution:
    def closestDivisors(self, num: int) -> List[int]:
        def divisors(x,arr):
            for i in range(1,int(math.sqrt(x))+1):
                if x%i==0:
                    arr.append(i)
                    arr.append(x//i)
            return arr
        a=[]
        b=[]
        divisors(num+1,a)
        divisors(num+2,b)
        a.sort()
        b.sort()
        min1=fabs(a[0]-a[len(a)-1])
        ind=0
        min2=fabs(b[0]-b[len(b)-1])
        ind2=0
        for i in range(len(a)//2):
            if fabs(a[i]-a[len(a)-i-1])<min1:
                min1=fabs(a[i]-a[len(a)-i-1])
                ind=i
        for j in range(len(b)//2):
            if fabs(b[j]-b[len(b)-j-1])<min2:
                min2=fabs(b[j]-b[len(b)-j-1])
                ind2=j
        x=[0,0]
        if min2<min1:
            x[0]=b[ind2]
            x[1]=b[ind2+1]
        else:
            x[0]=a[ind]
            x[1]=a[ind+1]
        return x
            

156