题目链接:
加或者减一个字符代价为x,字符数量翻倍代价为y,初始空字符,问你到n个字符的最小代价是多少。
dp[i]表示i个字符的最小代价。
当i为偶数个的时候,由+1或者*2得到。
当i为奇数个的时候,由+1或者*2-1得到。
1 //#pragma comment(linker, "/STACK:102400000, 102400000") 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 #include 10 #include 11 #include 12 #include