50分,一半tle

P1255 数楼梯

aishiteru_mitsu_ha @ 2024-03-07 17:51:33

#include<iostream>
using namespace std;
long long lt(long long n) {
    if (n == 1 || n == 0) {
        return 1;
    }
    return lt(n - 1) + lt(n - 2);
}
int main() {
    long long a;
    cin >> a;
    cout << lt(a);
    return 0;
}

by __Rickysun__ @ 2024-03-07 18:03:35

@not_much 这题是斐波那契数列,得用 dp ,当然,这种简单的 dp 其实就是地推,但是,由于 n<=5000unsigned~long~long 来了也扛不住(bushi,所以得用亿点点高精度


by xk2013 @ 2024-03-07 18:08:09

@not_much 用递推啊 awa


by xk2013 @ 2024-03-07 18:18:08

@Rickysun unsigned __int128 行不?


by yuhaiyue @ 2024-03-23 11:23:21

用递推


|