Run ID | Author | Problem | Lang | Verdict | Time | Memory | Code Length | Submit Time |
---|---|---|---|---|---|---|---|---|
34149 | charlotteJ | 菲波那契数 | C++ | Accepted | 0 MS | 244 KB | 240 | 2023-12-16 21:03:34 |
#include<iostream> using namespace std; int main(){ int k; cin>>k; int a1=1,a2=1,a3=0,i=2; if(k==1 or k==2) cout<<1; else{ do{ a3=a1+a2; a1=a2; a2=a3; i++; }while(i<k); cout<<a3; } return 0; }