开始计概A下半学期。
This commit is contained in:
1 parent
0cfdc8499c
commit
38e97654e1
31 files changed
+2144
-110
No files matched your search
@@ -3,18 +3,19 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
constexpr int MAX_N = 100;
|
||||
int cache[MAX_N * MAX_N];
|
||||
constexpr int MAX_N = 5001, MOD = 1e9 + 7;
|
||||
long long cache[MAX_N * MAX_N + MAX_N];
|
||||
|
||||
int get_split_solutions_count(int n, int parts_count) {
|
||||
long long 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;
|
||||
long long 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);
|
||||
ans %= MOD;
|
||||
}
|
||||
cache[n * MAX_N + parts_count] = ans;
|
||||
return ans;
|
||||
@@ -27,9 +28,10 @@ int main() {
|
||||
int n;
|
||||
while (cin >> n) {
|
||||
// cout << get_split_solutions_count(n, 2) << endl;
|
||||
int ans = 0;
|
||||
long long ans = 0;
|
||||
for (int i = 1; i <= n; i++) {
|
||||
ans += get_split_solutions_count(n, i);
|
||||
ans %= MOD;
|
||||
// clog << i << ":" << ans << " ";
|
||||
}
|
||||
cout << ans << endl;
|
||||
|
||||
Reference in new issue
Block a user