leetcode_650. 2 Keys Keyboard_dp
https://leetcode.com/problems/2-keys-keyboard/
初始一个A,两种操作,复制当前所有A,粘贴,问得到n个A最少需要多少步操作。
class Solution { public: int minSteps(int n) { vector<int> dp(n+1,10000); dp[1] = 0; for(int i=1;i<=n;i++) for(int j=2;j*i<=n;j++) dp[i*j] = min(dp[i]+j,dp[i*j]); return dp[n]; } };