
# squaresSum.py

'''
  Challenging Programming in Python
  Habib Izadkhah, Rashid Behzadidoost
  Springer, 2024
  Code 3.19

  n 		Expected output
  50  		(7,1)
  145		(12, 1)
  1480    	(38, 6)
  540		None
'''



def squaresSum(n):
  # return two integers whose squares sum to n

  # max value of first number
  max1 = int ((n/2)** 0.5)

  '''
    candidates for the second number
    cannot be more than the first
  '''
  candidates = set(range(1, 1+max1))
  for num2 in candidates:
    diff = n - (num2**2)
    sqRoot = int(diff**0.5)
    if sqRoot**2 == diff:
      return (sqRoot, num2)

  return None


# ------ main ----------

n = int(input("n? "))
print( squaresSum(n))
