QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#570995 | #9317. Rivals | NamingCrisis# | WA | 0ms | 1528kb | C++14 | 1.4kb | 2024-09-17 19:42:18 | 2024-09-17 19:42:19 |
Judging History
answer
#include <cstdio>
#include <cstring>
#include <cstdlib>
#define freopen(file)\
freopen(#file".in", "r", stdin);\
freopen(#file".out", "w", stdout);
#define ll long long
#define readl read<ll>()
#define readi read<int>()
template <class T>
inline T read() {
T x = 0, f = 1;
char c = getchar();
for (; c < '0' || c > '9'; c = getchar())
if (c == '-') f = -1;
for (; c <= '9' && c >= '0'; c = getchar())
x = (x << 1) + (x << 3) - '0' + c;
return x * f;
}
#define maxn 305
#define mod 998244353
int n, c, sc, sa, a[maxn];
int fac[maxn], finv[maxn];
inline int qp(int x, int y) {
int res = 1;
while (y) {
if (y & 1) res = (ll) res * x % mod;
x = (ll) x * x % mod, y >>= 1;
}
return res;
}
inline int inv(int x) {
return qp(x, mod - 2);
}
inline int C(int n, int m) {
if (n == m || !m) return 1;
return (ll) fac[n] * finv[m] % mod * finv[n - m] % mod;
}
int main() {
n = readi, c = readi;
for (int i = 1; i <= n; ++ i ) a[i] = readi;
for (int i = 1; i <= c; ++ i ) sc += a[i];
for (int i = 1; i <= n; ++ i ) sa += a[i];
fac[0] = 1;
for (int i = 1; i <= sa; ++ i )
fac[i] = (ll) fac[i - 1] * i % mod;
finv[sa] = inv(fac[sa]);
for (int i = sa - 1; ~ i; -- i )
finv[i] = (ll) finv[i + 1] * (i + 1) % mod;
for (int i = 1; i < sc; ++ i ) printf("0 ");
for (int i = sc; i <= sa; ++ i )
printf("%lld ", (ll)C(sa - sc, i - sc) * inv(C(sa, i)) % mod);
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 1528kb
input:
5 3 1 1 1 1 1
output:
0 0 299473306 199648871 1
result:
ok 5 tokens
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 1416kb
input:
8 5 3 5 3 2 2 5 4 4
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 351834787 638134827 932046441 601056881 109848214 439392856 539630643 840344004 918622482 453171246 134683762 681341384 534773761 1
result:
wrong answer 15th words differ - expected: '851829480', found: '351834787'