1. Problem
2. My Solution
import sys
import math
n = int(sys.stdin.readline().rstrip())
dp = [9999] * 100001
dp[0]=0
i = 1
while(i <= n):
sq = int(math.sqrt(i))
for j in range(1,sq+1):
dp[i] = min(dp[i], dp[i-j*j]+1)
i += 1
print(dp[n])
import sys
import math
n = int(sys.stdin.readline().rstrip())
dp = [0] * 100001
for i in range(1,100001):
sq = int(math.sqrt(i))
result =[]
for j in range(1,sq+1):
result.append(dp[i-(j*j)])
dp[i] = min(result)+1
print(dp[n])
3. Learned
if dp[i] > dp[i - j*j] + 1:
dp[i] = dp[i - j*j] + 1