Files
python/TangDou/AcWing/BeiBao/1023_2.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

20 lines
510 B
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <bits/stdc++.h>
using namespace std;
const int N = 1010;
int v[5] = {0, 10, 20, 50, 100};
int f[N];
// 体积限制是恰好是,因此需要初始化f[0][0]为合法解1,其他位置为非法解0。
int main() {
int m;
cin >> m;
// 前0种物品,体积是0的情况下只有一种方案
f[0] = 1;
for (int i = 1; i <= 4; i++)
for (int j = v[i]; j <= m; j++)
f[j] += f[j - v[i]];
// 输出
printf("%d\n", f[m]);
return 0;
}