文章
68
粉丝
691
获赞
26
访问
578.4k
https://blog.csdn.net/csyifanZhang/article/details/105342413
int main() {
int v[7] = {0, 1,2,3,5,10,20 }, a[7], dp[MAX];
for (int i = 1; i <= 6; i++)cin >> a[i];
memset(dp, 0, sizeof(dp));
int maxj = 0; dp[0] = 1;int res = 0;
for (int i = 1; i <= 6; i++) {
for (int j = maxj; j >= 0; j--) {
if (!dp[j])continue;
for (int k = 1; k <= a[i]; k++) {
if (dp[j + k * v[i]])break;
dp[j + k * v[i]] = 1;
}
}
maxj += a[i] * v[i];
maxj = min(1000, maxj);
}
for (int i = 1; i <= 1000; i++)
res += dp[i];
printf("Total=%d\n", res);
}
登录后发布评论
暂无评论,来抢沙发