洛谷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
相关文章
相关标签/搜索