文章
11
粉丝
20
获赞
4
访问
8.3k
#include<stdio.h>
int dp[31], w[21];
int main() {
int S, n;
scanf("%d%d", &S, &n);
for (int i = 1; i <= n; i++) scanf("%d", &w[i]);
dp[0] = 1;
for (int i = 1; i <= n; i++)
for (int j = S; j >= w[i]; j--)
dp[j] |= dp[j - w[i]];
if (dp[S]) puts("yes!");
else puts("no!");
}
登录后发布评论
暂无评论,来抢沙发