用的是递归,50分,剩下5个数据点超时了

P1255 数楼梯

aishiteru_mitsu_ha @ 2024-02-09 11:12:19

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

by xiaoshumiao @ 2024-02-09 11:13:06

@not_much

  1. 真要用递归需要记忆化

  2. 高精度标签被你吃了吗


by ForeverGodHdf @ 2024-02-10 20:24:13

用字符串


|