文章
71
粉丝
142
获赞
5
访问
50.7k
#include<iostream>
#include<cstring>
#include<map>
#include<string>
using namespace std;
const int maxn = 200;
int dp[maxn][maxn] = { 0 };//前i个物品是否能凑成重量为j;
int w[maxn];
int main() {
int s, n;
while (cin>>s>>n) {
memset(dp,0,sizeof(dp));
for (int i = 1; i <= n;i++) {
cin >> w[i];
}
for (int i = 0; i <= n; i++) {
dp[i][0] = 1;
}
for (int i = 1; i <= n;i++) {
for (int j = s; j >= 1;j--) {
if (j>=w[i]) {
&n...
登录后发布评论
暂无评论,来抢沙发