Run ID | Author | Problem | Lang | Verdict | Time | Memory | Code Length | Submit Time |
---|---|---|---|---|---|---|---|---|
44981 | 奚晨瑞 | Pell数列 | C++ | Accepted | 0 MS | 248 KB | 317 | 2024-04-07 15:23:43 |
#include<iostream> using namespace std; int f(int n){ if(n==1){ return 1; } else if(n==2){ return 2; } else{ return (2*f(n-1)+f(n-2)); } } int main() { int n; cin>>n; int a[n]; for(int i=0;i<n;i++){ cin>>a[i]; } for(int i=0;i<n;i++){ cout<<f(a[i])<<endl; } return 0; }