解题思路:动态规划,dp[0],dp[1] = 0, 大于2时,dp[i]=min(dp[i],dp[j]+i/j) (i%j==0)
class Solution(object):
def minSteps(self, n):
"""
:type n: int
:rtype: int
"""
dp = [2**32-1]*(n+1)
dp[0] = 0
dp[1] = 0
for i in range(2,n+1):
for j in range(1,i):
if i%j==0:
dp[i] = min(dp[i],dp[j]+i/j)
return dp[n]