提交时间:2023-10-10 13:14:41
运行 ID: 106175
#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]=g[2]=2; f[0]=g[1]=0; for(int i=3;i<=n;i++) { g[i]=f[i-2]*2+g[i-1]; f[i]=f[i-1]+f[i-2]+g[i-1]; } cout<<f[n]%10000; delete[] f; delete[] g; return 0; }