'commit'
This commit is contained in:
18
TangDou/AcWing/JiShuDP/900_1.cpp
Normal file
18
TangDou/AcWing/JiShuDP/900_1.cpp
Normal file
@@ -0,0 +1,18 @@
|
||||
#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;
|
||||
}
|
||||
Reference in New Issue
Block a user