显示代码纯文本
#include<bits/stdc++.h>
#define k 350
#define maxn 360
#define maxm 100010
using namespace std;
int n,mod,g[maxn][maxm],f[maxm];
int main(){
freopen("noi_online2020pj_running.in","r",stdin);
freopen("noi_online2020pj_running.out","w",stdout);
scanf("%d%d",&n,&mod);
g[0][0]=1;f[0]=1;
for(int i=1;i<=k;i++)
for(int j=k;j<=max(n,k);j++)
g[i][j]=(g[i-1][j-k]+g[i][j-i])%mod;
for(int i=1;i<=k;i++)
for(int j=i;j<=max(n,i);j++)
f[j]=(f[j]+g[i][j])%mod;
for(int i=1;i<=min(k-1,n);i++)
for(int j=i;j<=n;j++)f[j]=(f[j]+f[j-i])%mod;
printf("%d\n",f[n]);
return 0;
}