18 lines
414 B
C++
18 lines
414 B
C++
|
|
#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;
|
|||
|
|
}
|