标签:
#include <iostream> #include <algorithm> #include <cstring> #include <cstdio> using namespace std; const int INF = 2000, MOD = (int) 1e8 + 7; int g[INF], f[INF][INF]; int n, s, a, b; int main() { scanf ("%d %d %d %d", &n, &s, &a, &b); int tem = (2 * n - (a * n * (n - 1) / 2 % n) - s % n ) % n; for (int i = 2; i <= n; i++) g[i] = ( (a + b) * (n - i + 1) % n); f[1][tem] = 1; for (int i = 2; i <= n; i++) for (int j = 0; j < n; j++) { f[i][j] = (f[i][j] + f[i - 1][j]) % MOD; f[i][ (j + g[i]) % n] += f[i - 1][j]; f[i][ (j + g[i]) % n] %= MOD; } printf ("%d\n", f[n][0]); }
标签:
原文地址:http://www.cnblogs.com/keam37/p/4355972.html