1 条题解
-
0
#include <bits/stdc++.h> #define int long long using namespace std; const int MAXN = 20; const int MAXM = 3000; int n, m; int v[MAXN + 5]; int dp[MAXM + 5]; // dp[i] : 装满i的体积有多少种方案 signed main() { ios::sync_with_stdio(false); cin.tie(0); cin >> n >> m; for (int i = 1; i <= n; i++) cin >> v[i]; dp[0] = 1; for (int i = 1; i <= n; i++) { for (int j = v[i]; j <= m; j++) dp[j] = dp[j] + dp[j - v[i]]; } cout << dp[m] << "\n"; return 0; }
- 1
信息
- ID
- 492
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 5
- 标签
- (无)
- 递交数
- 35
- 已通过
- 14
- 上传者