DP是我致命的弱点,但CSP-J怎会不考DP?( ▼-▼ )
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
int m,n,c,x,y,le,ri;
int f[500][100001];
int main()
{
freopen("hack.in","r",stdin);
freopen("hack.out","w",stdout);
cin>>n>>c>>le>>ri;
le=le-c;
ri=ri-c;
c=0;
f[0][0]=1;
for(int i=1; i<=sqrt(2*n); i++)
{
for(int j=i; j<=ri; j++)
{
f[i][j]=f[i][j-i]+f[i-1][j-i];
f[i][j]=f[i][j]%998244353;
}
for(int j=le; j<=ri; j++)
{
c=c+f[i][j];
c=c%998244353;
}
}
cout<<c;
return 0;
}