设 d p [ i ] dp[i] dp[i]为和为i有多少种方式,然后dp就可以了……蠢了,居然没想到
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<sstream>
#include<queue>
#include<list>
#include<stack>
#include<bitset>
#include<cmath>
#include<map>
#define int long long
#define IO ios::sync_with_stdio(false)
using namespace std;
int s,dp[2005]={1};
const int mod=1e9+7;
signed main()
{
IO;
cin>>s;
for(int i=1;i<=s;i++)
{
for(int j=3;j<=i;j++)
{
dp[i]=(dp[i]+dp[i-j])%mod;
}
}
cout<<dp[s];
}