一封来自蒟蒻星的求助信

P1255 数楼梯

_NightFire666_ @ 2023-02-10 18:40:49

记忆化搜索+递归

#include<bits/stdc++.h>
using namespace std;

long long x[1000]; 
long long fun(int a){
    if(x[a]) return x[a];
    if(a==1||a==0) return 1;
    else return x[a]=fun(a-2)+fun(a-1);
}

int main(){
    int a;
    cin>>a;
    cout<<fun(a);
    return 0;
}

by _NightFire666_ @ 2023-02-10 18:42:20

记录


by JC_Lee @ 2023-02-10 18:44:30

@zhanghaoran666


by Elairin176 @ 2023-02-10 18:48:12

@zhanghaoran666 本题要用高精度


by JC_Lee @ 2023-02-10 18:49:45

@destructor zqd


by _NightFire666_ @ 2023-02-10 18:58:16

@destructor 谢谢


by _NightFire666_ @ 2023-02-10 19:10:28

谢谢大家,现在已经AC了


|