You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
#include <bits/stdc++.h>
|
|
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
|
|
const int N = 1010;
|
|
|
|
|
const int MOD = 1e9 + 7;
|
|
|
|
|
int n;
|
|
|
|
|
int f[N][N];
|
|
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
|
cin >> n;
|
|
|
|
|
for (int i = 1; i <= n; i++) f[i][0] = 1;
|
|
|
|
|
|
|
|
|
|
for (int i = 1; i <= n; i++) // 枚举每个物品,物品的序号与物品的体积是相等的,都是i
|
|
|
|
|
for (int j = 1; j <= n; j++) { // 枚举背包容量j
|
|
|
|
|
if (j >= i) // ① 背包容量j>=当前体积i,可以选择当前数字
|
|
|
|
|
f[i][j] = (f[i][j - i] + f[i - 1][j]) % MOD;
|
|
|
|
|
else
|
|
|
|
|
f[i][j] = f[i - 1][j] % MOD; // ② 放弃当前数字
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cout << f[n][n] << endl;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|