QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#488846 | #8815. Space Station | qL | WA | 61ms | 7892kb | C++14 | 980b | 2024-07-24 15:43:45 | 2024-07-24 15:43:45 |
Judging History
answer
#include <cstdio>
using i32 = int;
using i64 = long long;
constexpr i32 N = 100, A = 100;
constexpr i32 mod = 998244353;
i32 n, m;
i32 f[N + 1][A * N + 1];
i32 binom[N + 1][N + 1];
i64 qpow(i64 x, i64 p) noexcept {
i64 r = 1;
for (; p; p >>= 1, (x *= x) %= mod)
if (p & 1) (r *= x) %= mod;
return r;
}
signed main() noexcept {
scanf("%d%d", &n, &m);
for (i32 i = 0; i <= n; ++i) {
binom[i][0] = 1;
for (i32 j = 1; j <= i; ++j) binom[i][j] = (binom[i - 1][j - 1] + binom[i - 1][j]) % mod;
}
f[0][0] = 1;
for (i32 i = 1, a; i <= n; ++i) {
scanf("%d", &a);
for (i32 j = i; j; --j)
for (i32 v = a; v <= n * A; ++v) (f[j][v] += f[j - 1][v - a]) %= mod;
}
i64 ans = 0;
for (i32 i = 1; i <= n; ++i) {
i64 pick = qpow(binom[n][i], mod - 2), invi = qpow(i, mod - 2);
for (i32 sum = 0; sum <= n * A; ++sum)
(ans += (sum < m * i ? sum * invi % mod : m) * pick % mod * f[i][sum]) %= mod;
}
printf("%lld\n", ans);
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3776kb
input:
3 3 2 3 4
output:
499122185
result:
ok 1 number(s): "499122185"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3836kb
input:
5 1 10 20 30 40 50
output:
5
result:
ok 1 number(s): "5"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3884kb
input:
1 9 37
output:
9
result:
ok 1 number(s): "9"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3828kb
input:
5 5 24 41 29 6 40
output:
25
result:
ok 1 number(s): "25"
Test #5:
score: 0
Accepted
time: 1ms
memory: 3996kb
input:
10 34 91 86 1 14 98 13 85 64 91 20
output:
707882334
result:
ok 1 number(s): "707882334"
Test #6:
score: 0
Accepted
time: 61ms
memory: 7892kb
input:
100 9 83 99 170 80 174 137 1 91 111 35 69 39 148 76 142 90 105 30 114 176 196 85 26 109 162 167 171 148 169 162 159 3 4 6 33 61 163 7 77 63 8 20 13 51 26 11 149 136 134 187 96 95 113 104 128 48 167 74 18 91 200 62 167 32 5 180 189 39 63 111 68 72 81 128 42 13 57 180 111 91 83 177 34 45 158 29 114 33...
output:
82380556
result:
ok 1 number(s): "82380556"
Test #7:
score: -100
Wrong Answer
time: 61ms
memory: 7736kb
input:
100 33 24 157 144 142 151 8 93 54 189 74 12 129 77 95 59 13 159 48 67 116 174 194 9 166 170 84 136 68 39 181 133 190 37 115 42 95 134 148 91 59 130 1 68 48 14 126 193 50 192 196 44 85 37 96 66 39 180 129 22 2 17 101 45 159 171 68 113 142 197 156 63 96 185 108 72 69 144 33 115 142 139 11 57 76 126 19...
output:
621942902
result:
wrong answer 1st numbers differ - expected: '516465986', found: '621942902'