刚开始滚动数组错了
#include <iostream>
#include <algorithm>
#include <cstring>
#include <functional>
#include <cmath>
using namespace std;
typedef long long ll;
const int MAXN = 100005;
const int MAXNUM = 320;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int NIL = -1;
const int mod = 998244353;
int dp[MAXN][2]; //dp[i][j]将i划分为j个的不同整数的划分数int main(void)
{freopen("in.txt", "r", stdin);freopen("out.txt", "w", stdout);ios::sync_with_stdio(false);cin.tie(0);int T, N, C, L, R;cin >> T;while (T--){cin >> N >> C >> L >> R;dp[0][0] = 1;L -= C;R -= C;int ans = L == 0 ? 1 : 0;/*for (int i = 1; i <= R; ++i){int num = sqrt(2 * i);if (num * (num + 1) < i)++num;for (int j = 1; j <= num; ++j){if (j == 1)dp[i][j] = 1;else if (i <= j)dp[i][j % 2] = 0;elsedp[i][j % 2] = (dp[i - j][j % 2] + dp[i - j][(j - 1) % 2]) % mod;if (L <= i)ans = (ans + dp[i][j % 2]) % mod;}}滚动数组的顺序有讲究*/memset(dp, 0, sizeof(dp));dp[0][0] = 1;for (int j = 1; (j + 1) * j / 2 <= R; ++j) //j在滚动{for (int i = (j + 1) * j / 2; i <= R; ++i){dp[i][j % 2] = (dp[i - j][j % 2] + dp[i - j][(j - 1) % 2]) % mod;if (L <= i && i <= R)ans = (ans + dp[i][j % 2]) % mod;}for (int i = 0; i <= R; ++i)dp[i][(j - 1) % 2] = 0;}cout << ans << endl;}return 0;
}