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.

18 lines
414 B

2 years ago
#include <bits/stdc++.h>
using namespace std;
const int N = 1010;
const int MOD = 1e9 + 7;
int f[N];
int n;
int main() {
cin >> n;
f[0] = 1; // 容量为0时前 i 个物品全不选也是一种方案
for (int i = 1; i <= n; i++)
for (int j = i; j <= n; j++) // 完全背包从小到大
f[j] = (f[j] + f[j - i]) % MOD;
cout << f[n] << endl;
return 0;
}