classSolution(object):defnumSquares(self, n):"""
:type n: int
:rtype: int
"""import math
while n%4==0:
n=n//4if n %8==7:return4for i inrange(int(math.sqrt(n)),0,-1):
b = n - i*i
if b ==0:return1for j inrange(int(math.sqrt(b)),0,-1):
c = b - j*j
if c ==0:return2return3