#include <iostream>
using namespace std;
int climbStairs(int n) {
int f1 = 2;
int f2 = 1;
if(n == 1) {
return f2;
} else if(n == 2) {
return f1;
}
int fn;
for(int i = 3; i <= n; i++) {
fn = f1 + f2;
f2 = f1;
f1 = fn;
}
return fn;
}
int main() {
cout << climbStairs(5);
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IGNsaW1iU3RhaXJzKGludCBuKSB7CiAgICBpbnQgZjEgPSAyOwogICAgaW50IGYyID0gMTsKICAgIGlmKG4gPT0gMSkgewogICAgICAgIHJldHVybiBmMjsKICAgIH0gZWxzZSBpZihuID09IDIpIHsKICAgICAgICByZXR1cm4gZjE7CiAgICB9CgogICAgaW50IGZuOwogICAgZm9yKGludCBpID0gMzsgaSA8PSBuOyBpKyspIHsKICAgICAgICBmbiA9IGYxICsgZjI7CiAgICAgICAgZjIgPSBmMTsKICAgICAgICBmMSA9IGZuOwogICAgfQogICAgcmV0dXJuIGZuOwp9CgppbnQgbWFpbigpIHsKCWNvdXQgPDwgY2xpbWJTdGFpcnMoNSk7CglyZXR1cm4gMDsKfQ==