This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
#include <bits/stdc++.h>
using namespace std;
const int N = 5;
const int M = 1010;
int v[N] = {0, 10, 20, 50, 100}; // 每种货币,下标从1开始
int n, m; // 货币种类,钱数
int f[N][M]; // 前i种物品,体积恰好是j的情况下的最大值
// 完全背包
int main() {
n = 4;
cin >> m;
// 前0种物品,体积是0的情况下只有一种方案
// 一般询问方案数的问题f[0]都会设置为1
// Q:那20元钱呢?不买;买两本10块的;每一本20的。三种呀
// A:题目说的全部,钱要花完
f[0][0] = 1;
for (int i = 1; i <= n; i++) // 每个物品
for (int j = 0; j <= m; j++) // 每个体积
for (int k = 0; v[i] * k <= j; k++) // 个数
f[i][j] += f[i - 1][j - v[i] * k];
printf("%d\n", f[n][m]);
return 0;
}