看一下数据量,只有一千,说明这个不是数学问题
#include<bits/stdc++.h>
using namespace std;#define int long long
const int mo = 100000007;
int n, s, a, b;
const int N = 1005;// +2 -3
// 1 3 5 2 -1
// 1 -2 -5 -3 -1
int dp[N][N];
int fun(int x) {return (x % n + n) % n;
}signed main() {cin >> n >> s >> a >> b;dp[0][0] = 1;for (int i = 1; i < n; i++) {for (int j = 0; j < n; j++) {dp[i][j] = (dp[i - 1][fun(j - a * i)] + dp[i - 1][fun(j + b * i)])%mo;}}cout << dp[n - 1][fun(s)];return 0;
}