Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
148158 编程星球01 小明养猪的故事 C++ Accepted 0 MS 276 KB 416 2026-02-09 19:34:49

Tests(1/1):


Code:

#include<bits/stdc++.h> using namespace std; int f(int n) { if(n == 1) { return 1; } if(n == 2) { return 2; } if(n == 3) { return 3; } return f(n-1) * 2 - f(n-3); } int main() { int n; cin >> n; for(int i=0;i<n;i++) { int m; cin >> m; cout << f(m) <<endl; } return 0; }