QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#605651#7875. Queue SortinglonelywolfWA 0ms3652kbC++20824b2024-10-02 18:19:342024-10-02 18:19:35

Judging History

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

  • [2024-10-02 18:19:35]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3652kb
  • [2024-10-02 18:19:34]
  • 提交

answer

#include <bits/stdc++.h>  
using namespace std;  

#define int long long  

const int mod = 998244353;

int qpow(int a, int b) {
	int res = 1;
	for (; b; b /= 2, a = a * a % mod) {
		if (b % 2) {
			res = res * a % mod;
		}
	}
	return res;
}

int inv(int a) {
	return qpow(a, mod - 2);
}

signed main() {  
    ios::sync_with_stdio(false);
    cin.tie(nullptr);  

	int n;
	cin >> n;

	int s = 0;
	vector<int> a(n + 1);
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		s += a[i];
	}

	vector<int> fac(2 * s + 1, 1);
	for (int i = 1; i <= 2 * s; i++) {
		fac[i] = fac[i - 1] * i % mod;
	}

	int ans = fac[2 * s] * inv(fac[s]) % mod * inv(fac[s + 1]) % mod;


	for (int i = 1; i <= n; i++) {
		ans = ans * inv(fac[a[i]]) % mod;
	}

	cout << ans << "\n";

    return 0;
}  
  

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3652kb

input:

4
1 1 1 1

output:

14

result:

ok 1 number(s): "14"

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3504kb

input:

300
0 5 2 2 1 0 3 2 2 5 2 1 1 2 1 3 2 3 2 0 0 0 0 1 2 2 3 0 2 2 3 2 0 2 3 0 6 0 0 2 0 1 3 2 1 1 1 3 4 0 1 0 4 1 1 1 1 1 1 2 3 2 1 2 3 2 3 0 5 3 3 2 0 1 1 0 2 1 1 2 0 0 2 1 1 3 2 2 1 2 1 3 0 3 0 1 2 2 0 5 0 2 2 0 0 0 1 2 1 4 2 1 1 0 3 0 2 0 3 1 1 2 0 2 1 1 0 2 0 1 2 2 3 3 1 1 1 1 0 1 3 3 1 0 2 2 4 2 ...

output:

124974879

result:

wrong answer 1st numbers differ - expected: '507010274', found: '124974879'