Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
99539 唐安轩 斐波那契数列 C++ Accepted 1 MS 280 KB 359 2024-11-30 11:32:29

Tests(11/11):


Code:

#include <iostream> using namespace std; int main() { int k; cin>>k; if(k == 0){ cout<< "0" <<endl; return 0; }else if(k == 1){ cout<<"1"<<endl; return 0; } int a=0,b=1,f=0; for (int i=2;i<=k;i++){ f=a+b; a=b; b=f; } cout<<f<<endl; return 0; }