Runtime Error
代码
#include <iostream>
#define N 1000000
using namespace std;
int dp[N];
int fun(int n)
{
if(n<=3)
{
dp[1]= 1;
dp[2]= 2;
dp[3]= 4;
}
else
dp[n] = ((dp[n-1]+dp[n-2])% 1000000007+dp[n-3])% 1000000007;
return dp[n];
}
int main()
{
int n;
cin>>n;
for(int i=1;i<=n;i++)
fun(i);
cout<<dp[n]<<endl;
}