Files
python/TangDou/AcWing/JiShuDP/900_1.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

18 lines
414 B
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#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;
}