Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
36517 | 傅煜琦 | 小明养猪的故事 | C++ | Accepted | 2 MS | 724 KB | 241 | 2022-08-09 12:08:54 |
#include<bits/stdc++.h> using namespace std; int main(){ int a[25]; int n; int 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; }