kxr2010 @ 2022-10-03 21:10:37
#include<bits/stdc++.h>
using namespace std;
int s,n;
void go(int i){
if(i>=n){
s++;
return;
}
go(i+1);
go(i+2);
}
int main(){
cin>>n;
go(1);
cout<<s;
return 0;
}
by kxr_ @ 2022-10-03 21:12:50
我和你一样
by dengchengzhuo @ 2022-10-03 21:13:49
不能用递归的
by dengchengzhuo @ 2022-10-03 21:14:42
时间复杂度爆表,建议以后学DP再做这题
by dengchengzhuo @ 2022-10-03 21:15:00
@kxr2010
by kxr_ @ 2022-10-03 21:24:06
@dengchengzhuo 谢谢大佬!
by vdfes @ 2022-10-03 21:29:09
@dengchengzhuo
加上记忆化后,时间复杂度应该和
虽然他没加