Files
python/TangDou/AcWing/JiShuDP/900_1.cpp

18 lines
414 B
C++
Raw Normal View History

2025-08-30 18:35:01 +08:00
#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;
}