YanQingDD @ 2023-08-13 09:27:52
#include <iostream>
using namespace std;
int n,m;
int shulouti(int n){
if(n==1)return 1;
else if(n==2)return 2;
return shulouti(n-1)+shulouti(n-2);
}
int main(){
cin>>n;
m=shulouti(n);
cout<<m;
return 0;
}
by AndyPomeloMars @ 2023-08-13 09:31:51
@YanQingDD 请使用高精度
by YanQingDD @ 2023-08-13 09:32:36
@Apm 超时了
by YanQingDD @ 2023-08-13 09:32:59
@Apm TLE
by AndyPomeloMars @ 2023-08-13 09:33:57
@YanQingDD 你超时了也得改
by AndyPomeloMars @ 2023-08-13 09:36:54
@YanQingDD 然后加一个记忆化搜索
by YanQingDD @ 2023-08-13 09:37:02
@Apm OK,那怎么记忆化搜索
by YanQingDD @ 2023-08-13 09:37:52
求大佬指点@Apm
by AndyPomeloMars @ 2023-08-13 09:39:52
@YanQingDD 用一个数组来记录你f(x)的结果
by AndyPomeloMars @ 2023-08-13 09:41:19
@YanQingDD 高精+菲波那切数列+递推
by YanQingDD @ 2023-08-13 09:42:07
@Apm f(x)?