60分求调!

P1255 数楼梯

caojiashu @ 2024-01-17 18:36:49

#include <iostream>
using namespace std;
int main(){
    int n;
    unsigned long long a = 1, b = 2, c;
    cin >> n;
    if (n == 1){
        c = 1;
    }
    else if (n == 2){
        c = 2;
    }
    for (int i = 3; i <= n; i ++){
        c = a + b;
        a = b; b = c;
    }
    cout << c;
}

by zjpwdyf @ 2024-01-17 18:47:24

@caojiashu 此题需要用到高精度


by caojiashu @ 2024-01-17 18:49:25

@zjpwdyf 谢谢,已经解决


|