状态转移方程:(f(i) = f(i - 1) + f(i - 2) + s(i - 3) * 2),其中(s(k) = f(1) + ... + f(k))
#include<iostream>
using namespace std;
const int N = 1e6 + 10, mod = 10000;
int f[N], s[N];
int n;
int main(){
cin >> n;
f[0] = f[1] = 1;
f[2] = 2;
s[0] = f[0];
for(int i = 1; i <= n; i ++){
if(i >= 3) f[i] = (f[i - 1] + f[i - 2] + s[i - 3] * 2) % mod;
s[i] = (s[i - 1] + f[i]) % mod;
}
cout << f[n];
}