这个题是相当的神奇,相对于背包装满问题的方案个数,需要将两个循环的位置进行交换。和完全背包和01背包的关系有些相似,代码如下:
typedef unsigned long long ll;
class Solution {
public:
int combinationSum4(vector<int>& nums, int target) {
ll dp[target+1];
memset(dp, 0, sizeof(dp)
这个题是相当的神奇,相对于背包装满问题的方案个数,需要将两个循环的位置进行交换。和完全背包和01背包的关系有些相似,代码如下:
typedef unsigned long long ll;
class Solution {
public:
int combinationSum4(vector<int>& nums, int target) {
ll dp[target+1];
memset(dp, 0, sizeof(dp)