Written By : MathModel
Notice that 1 \le a < b \le 10^4 , thus the maximum integer that we'll get is , thus we should be using a language that supports big integers like Python.
From the constraints we also should pick "elegant" brute force , we can name the input integer as , we iterate from a=2 to a=10^4 and b=a+1 to b=10^4 , this is roughly 10^8 operations which is quite much , we can optimize this by dropping the cases that we want , which is exactly
Once this product is larger than we're just increasing and consuming time for no good reason , thus we just break once we've it ready.
Complexity roughly \mathcal{O}(10^7) which is a better optimization.
def solve():
n=int(input())
for a in range(2,10**4+1):
cur=a
for b in range(a+1,10**4+1):
cur*=b
if(cur==n):
print(a,b)
return
if(cur>n):
break
solve()