普通的解法:)

P1255 数楼梯

LCMCat @ 2020-10-04 09:36:31

#include<bits/stdc++.h>
using namespace std;
int step(int st){
    if(st==1) return 1;
    else if(st==2) return 2;
    else return step(st-1)+step(st-2);
}
int main(){
    int ipt;
    cin>>ipt;
    cout<<step(ipt);
}

TLE和MLE出错

下载测试样例后才发现神TM有个5000

by zhy137036 @ 2020-10-04 09:37:37

记忆化/递推


by zhy137036 @ 2020-10-04 09:38:12

还有毒瘤高精...


by Eason_AC @ 2020-10-04 09:44:15

???


by BotDand @ 2020-10-04 09:55:35

高精+记忆化


by Argon_Cube @ 2020-10-04 10:45:03

@LinuxCMCat 从LeetCode学到的


by LCMCat @ 2020-10-04 19:54:21

@Unnamed_Cube 这是一个很经典的解题算法,NOIP一本通上就有


|