From 8cb75eb6bdb9b5f51b3f438ce44addeceb136a64 Mon Sep 17 00:00:00 2001 From: Baoshuo Ren Date: Fri, 28 Jan 2022 14:05:40 +0800 Subject: [PATCH] =?UTF-8?q?278.=20=E6=95=B0=E5=AD=97=E7=BB=84=E5=90=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://www.acwing.com/problem/content/submission/code_detail/10435503/ --- AcWing/278/278.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 AcWing/278/278.cpp diff --git a/AcWing/278/278.cpp b/AcWing/278/278.cpp new file mode 100644 index 00000000..5efc0186 --- /dev/null +++ b/AcWing/278/278.cpp @@ -0,0 +1,25 @@ +#include + +using std::cin; +using std::cout; +#define endl '\n' + +const int N = 105, + M = 10005; + +int n, m, a[N], f[M]; + +int main() { + cin >> n >> m; + for (int i = 1; i <= n; i++) { + cin >> a[i]; + } + f[0] = 1; + for (int i = 1; i <= n; i++) { + for (int j = m; j >= a[i]; j--) { + f[j] += f[j - a[i]]; + } + } + cout << f[m] << endl; + return 0; +}