Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
36520 郑皓 小明养猪的故事 C++ Accepted 2 MS 724 KB 227 2022-08-09 12:09:45

Tests(1/1):


Code:

#include<bits/stdc++.h> using namespace std; int main(){ int a[25],n,t; cin>>t; a[1]=1; a[2]=2; while(t--){ cin>>n; for(int i=3;i<=n;i++){ a[i]=a[i-1]+a[i-2]; } cout<<a[n]<<endl; } return 0; }