| Run ID | 作者 | 问题 | 语言 | 测评结果 | 时间 | 内存 | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|
| 73832 | sh25_shenpy | 斐波那契数列_记忆化递归 | C++ | 通过 | 0 MS | 256 KB | 693 | 2025-11-16 20:46:22 |
#include <bits/stdc++.h> using namespace std; int main( ) { long n; cin>>n; long j1=1,j2=1,j3=0,i=1; if(n==1||n==2) { cout<<j1; } else if(n%3==0) { while(i<=(n/3)) { i+=1; j3=j1+j2; j1=j2+j3; j2=j3+j1; } cout<<j3; } else if(n%3==1) { while(i<=(n-1)/3) { i+=1; j3=j1+j2; j1=j2+j3; j2=j3+j1; } cout<<j1; } else { while(i<=(n-2)/3) { i+=1; j3=j1+j2; j1=j2+j3; j2=j3+j1; } cout<<j2; } return 0; }