Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
103746 | 刘泽熙 | 斐波那契数列(递归) | C++ | Accepted | 1 MS | 272 KB | 261 | 2024-12-29 15:06:15 |
#include <bits/stdc++.h> using namespace std; int main() { int k, n2 = 1, n1 = 1, t; cin >> k; if (k <= 2) { cout << 1; } else { for (int i = 3; i <= k; ++i) { t = n1 + n2; n2 = n1; n1 = t; } cout << n1; } return 0; }