0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-09-19 00:05:25 +00:00

#1461. 【2022.7.5】豌豆射手

https://sjzezoj.com/submission/53419
This commit is contained in:
Baoshuo Ren 2022-07-05 22:33:04 +08:00
parent 7477da6e72
commit 537ff4a159
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A
14 changed files with 121 additions and 0 deletions

82
S2OJ/1461/1461.cpp Normal file
View File

@ -0,0 +1,82 @@
#include <iostream>
#include <algorithm>
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;
}

BIN
S2OJ/1461/data/problem.conf (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1461/data/shooter1.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1461/data/shooter1.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1461/data/shooter2.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1461/data/shooter2.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1461/data/shooter3.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1461/data/shooter3.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1461/data/shooter4.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1461/data/shooter4.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1461/data/shooter5.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1461/data/shooter5.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1461/data/shooter6.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1461/data/shooter6.out (Stored with Git LFS) Normal file

Binary file not shown.