提交时间:2023-11-25 08:08:31

运行 ID: 111791

#include <bits/stdc++.h> using namespace std; int main(){ int n; cin>>n; long long a = 1; long long b = 2; long long c = 0; if(n==1){ cout<<"1"<<endl; return 0; } if(n==2){ cout<<"2"<<endl; return 0; } for(int i = 3;i<=n;i++){ c = a+b; a = b; b = c; } cout<<c<<endl; return 0; }