TAG
- 芝士水题、算法 − 【递归】 芝士水题、算法 - 【递归】 芝士水题、算法−【递归】时间复杂度
- O ( ∗ ) O(\ast) O(∗)
//
#include <bits/stdc++.h>
using namespace std;
// #define int long long
int f(int n) {
if (n <= 0) return 1;
int cnt = 0;
for (int i = 0; i <= n / 2; i++) {
cnt += f(i);
}
return cnt;
}
void solve() {
int n;
cin >> n;
cout << f(n) << endl;
}
signed main() {
int t = 1;
// scanf("%d", &t);
while (t--) solve();
return 0;
}
实现细节
- `
参考示意图
-
`
参考链接
- `
作者 | 乐意奥AI