提交时间:2023-10-05 17:08:36
运行 ID: 105231
#include<bits/stdc++.h> using namespace std; int a[1000005],g[1000005]; int main() { int n; cin>>n; a[1]=1; a[2]=2; g[2]=1; for(int i=3;i<=n;i++) { a[i]=(a[i-1]+2*a[i-2]+g[i-1])%1000; g[i]=(g[i-1]+a[i-2])%1000; } cout<<a[n]<<endl; }