Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
147965 王峻熙 小明养猪的故事 C++ Accepted 0 MS 268 KB 414 2026-02-09 09:35:18

Tests(1/1):


Code:

#include <iostream> using namespace std; int Fib(int n) { if (n == 1) return 1; if (n == 2) return 2; int a = 1; int b = 2; int c; for (int i = 3; i <= n; i++) { c = a + b; a = b; b = c; } return c; } int main() { int T, N; cin >> T; while (T--) { cin >> N; cout << Fib(N) << endl; } return 0; }