题目
题目链接:https://www.luogu.com.cn/problem/P1028
不太会递归 找几道基础题!
代码
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<cctype>
#include<ctime>
#include<iostream>
#include<string>
#include<map>
#include<queue>
#include<stack>
#include<set>
#include<vector>
#include<iomanip>
#include<list>
#include<bitset>
#include<sstream>
#include<fstream>
#include<complex>
#include<algorithm>
#if __cplusplus >= 201103L
#include <unordered_map>
#include <unordered_set>
#endif
#define ll long long
using namespace std;
const int INF = 0x3f3f3f3f;
int a[100100];
int f(int n){
if(a[n]) return a[n];
int res=1;
for(int i=1;i<=n/2;i++){
res+=f(i);
}
return a[n]=res;
}
int main(){
ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int n;
cin>>n;
cout<<f(n)<<endl;
return 0;
}