提交时间:2023-10-05 08:55:04

运行 ID: 105038

#include<bits/stdc++.h> using namespace std; int main() { int n; unsigned long long *f,*g; cin>>n; f=new unsigned long long[n+1]; g=new unsigned long long[n+1]; f[1]=1; f[2]=2; g[1]=1; g[2]=1; for(int i=3;i<=n;i++) { g[i]=g[i-2]*2; f[i]=f[i-1]+f[i-2]+g[i]; } cout<<f[n]; delete[] f; delete[] g; return 0; }