40 lines
990 B
C++
40 lines
990 B
C++
#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;
|
|
}
|