Update CMakeLists.txt

This commit is contained in:
2026-09-05 11:05:50 +08:00
parent 94bdf44889
commit a7a78fbac8
22 changed files with 1339 additions and 52 deletions
+39
View File
@@ -0,0 +1,39 @@
#include <iostream>
#include <unordered_map>
using namespace std;
constexpr int MAX_N = 100;
int cache[MAX_N * MAX_N];
int get_split_solutions_count(int n, int parts_count) {
if (n <= 0 || parts_count > n) { return 0; }
if (parts_count == 1 || parts_count == n) { return 1; }
if (cache[n * MAX_N + parts_count] != 0) {
return cache[n * MAX_N + parts_count];
}
int ans = 0;
for (int i = 1; i <= n / 2; i++) {
ans += get_split_solutions_count(n - i - (i - 1) * (parts_count - 1), parts_count - 1);
}
cache[n * MAX_N + parts_count] = ans;
return ans;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
while (cin >> n) {
// cout << get_split_solutions_count(n, 2) << endl;
int ans = 0;
for (int i = 1; i <= n; i++) {
ans += get_split_solutions_count(n, i);
// clog << i << ":" << ans << " ";
}
cout << ans << endl;
}
return 0;
}