QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#571001#9317. RivalsNamingCrisis#WA 0ms1500kbC++141.4kb2024-09-17 19:46:072024-09-17 19:46:08

Judging History

你现在查看的是最新测评结果

  • [2024-09-17 19:46:08]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:1500kb
  • [2024-09-17 19:46:07]
  • 提交

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: 1500kb

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: 1492kb

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'