洛谷P2347 砝碼稱重 某一年noip提高組原題

可以轉化爲01揹包求方案數的問題,dp數組f[][]表示第幾個砝碼能稱出的重量,可壓縮至一維 轉移方程爲f(i,j)+=f(i-1,j-w[i]) 當前我們可以稱出的重量必定是由之前的砝碼重量轉移過來的 #include<bits/stdc++.h> using namespace std; const int N=550; const int maxn=1e6+7; int f[maxn]; i
相關文章
相關標籤/搜索