diff --git a/S2OJ/1461/1461.cpp b/S2OJ/1461/1461.cpp new file mode 100644 index 00000000..033d5727 --- /dev/null +++ b/S2OJ/1461/1461.cpp @@ -0,0 +1,82 @@ +#include +#include + +using std::cin; +using std::cout; +const char endl = '\n'; + +const int N = 45, + D = 1e5 + 5; +const int mod = 1e9 + 7; + +int n, d, r[N], f[N][N][N * N], ans; +int fac[D], inv[D]; + +int binpow(int a, int b) { + int res = 1; + a %= mod; + while (b) { + if (b & 1) res = 1ll * res * a % mod; + a = 1ll * a * a % mod; + b >>= 1; + } + return res; +} + +inline int C(int n, int m) { + return 1ll * fac[n] * inv[m] % mod * inv[n - m] % mod; +} + +int main() { + std::ios::sync_with_stdio(false); + cin.tie(nullptr); + + // factorial + fac[0] = 1; + for (int i = 1; i <= 100000; i++) { + fac[i] = 1ll * fac[i - 1] * i % mod; + } + + // inverse + inv[100000] = binpow(fac[100000], mod - 2); + + for (int i = 99999; i >= 0; i--) + inv[i] = 1ll * inv[i + 1] * (i + 1) % mod; + + // main + cin >> n >> d; + + for (int i = 1; i <= n; i++) { + cin >> r[i]; + } + + std::sort(r + 1, r + 1 + n); + + f[0][0][0] = 1; + + for (int i = 0; i <= n; i++) { + for (int j = 0; j <= i; j++) { + for (int k = 0; k <= 40 * 40; k++) { + int t = r[i + 1]; + + if (j >= 1) { + f[i + 1][j][k + t] = (f[i + 1][j][k + t] + 1ll * f[i][j][k] * 2 * j) % mod; + } + + if (j >= 2) { + f[i + 1][j - 1][k + t * 2 - 1] = (f[i + 1][j - 1][k + t * 2 - 1] + 1ll * f[i][j][k] * j * (j - 1)) % mod; + } + + f[i + 1][j + 1][k + 1] = (f[i + 1][j + 1][k + 1] + f[i][j][k]) % mod; + } + } + } + + for (int i = 0; i <= std::min(d, 40 * 40); i++) { + ans = (ans + 1ll * C(d - i + n, n) * f[n][1][i] % mod) % mod; + } + + cout << ans << endl; + + return 0; +} diff --git a/S2OJ/1461/data/problem.conf b/S2OJ/1461/data/problem.conf new file mode 100644 index 00000000..99fb89ce --- /dev/null +++ b/S2OJ/1461/data/problem.conf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d801f4c2cad46f8e3b417fe0000c22c9b75cfe7ff786f00a68bb8f36eac08d99 +size 182 diff --git a/S2OJ/1461/data/shooter1.in b/S2OJ/1461/data/shooter1.in new file mode 100644 index 00000000..91cf739b --- /dev/null +++ b/S2OJ/1461/data/shooter1.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1098a762fa2f09c9ce93f2e15647ee7e5ce901893f216de9cc5b0b06c366c2db +size 15 diff --git a/S2OJ/1461/data/shooter1.out b/S2OJ/1461/data/shooter1.out new file mode 100644 index 00000000..d3cb9933 --- /dev/null +++ b/S2OJ/1461/data/shooter1.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:77230171f17a01512ec67c9796c349ba8f3cdf731905c077396384628e5bbd47 +size 6 diff --git a/S2OJ/1461/data/shooter2.in b/S2OJ/1461/data/shooter2.in new file mode 100644 index 00000000..9cf75d89 --- /dev/null +++ b/S2OJ/1461/data/shooter2.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:14e36a13ce84ce22bdbfb6645f5196aab723819f3fcfe426bef7adc105ea869b +size 15 diff --git a/S2OJ/1461/data/shooter2.out b/S2OJ/1461/data/shooter2.out new file mode 100644 index 00000000..ae5e961f --- /dev/null +++ b/S2OJ/1461/data/shooter2.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:eac49b0badacd9a2b90dda6621d141162732bf83418d0d76cc4c422f28eb4f1d +size 4 diff --git a/S2OJ/1461/data/shooter3.in b/S2OJ/1461/data/shooter3.in new file mode 100644 index 00000000..4fc73e2f --- /dev/null +++ b/S2OJ/1461/data/shooter3.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:287624d71fb2dd2c54a10ce93def18e0a706ea1e0f5eb2946ba579a44364f85f +size 67 diff --git a/S2OJ/1461/data/shooter3.out b/S2OJ/1461/data/shooter3.out new file mode 100644 index 00000000..56081310 --- /dev/null +++ b/S2OJ/1461/data/shooter3.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f337392b1ed58c07bb1dd1a278d4bdc4d352ef25131b2a6608e288bed3417b57 +size 9 diff --git a/S2OJ/1461/data/shooter4.in b/S2OJ/1461/data/shooter4.in new file mode 100644 index 00000000..94371b9d --- /dev/null +++ b/S2OJ/1461/data/shooter4.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6f48bdbc1256072d899a813e90bc1aece293b56196b2b10b4c930f48c41f0bfe +size 66 diff --git a/S2OJ/1461/data/shooter4.out b/S2OJ/1461/data/shooter4.out new file mode 100644 index 00000000..64e2f89f --- /dev/null +++ b/S2OJ/1461/data/shooter4.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bebb74e885042e396383107fa417bc89728eb316eb8aef35bf5e9adade0ce27b +size 10 diff --git a/S2OJ/1461/data/shooter5.in b/S2OJ/1461/data/shooter5.in new file mode 100644 index 00000000..2d2a393f --- /dev/null +++ b/S2OJ/1461/data/shooter5.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e8316d9f0c88425471d3ffce68cfbb702bcab73b187b53a516eb7575adec898e +size 122 diff --git a/S2OJ/1461/data/shooter5.out b/S2OJ/1461/data/shooter5.out new file mode 100644 index 00000000..325d2075 --- /dev/null +++ b/S2OJ/1461/data/shooter5.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6ea2b459665735d052fdd4f776088a5951d77a870c29a48205809cbd3c8ec468 +size 9 diff --git a/S2OJ/1461/data/shooter6.in b/S2OJ/1461/data/shooter6.in new file mode 100644 index 00000000..b170488a --- /dev/null +++ b/S2OJ/1461/data/shooter6.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b39d9f5c749d3ac232d1a8d67723edb30e83a9bcd5527630f22b2956d35a0027 +size 126 diff --git a/S2OJ/1461/data/shooter6.out b/S2OJ/1461/data/shooter6.out new file mode 100644 index 00000000..d5591f13 --- /dev/null +++ b/S2OJ/1461/data/shooter6.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4b16818914836c8de75ddebd24ffbf420b215ab5bbabdbeb5b7807c43d77f457 +size 10