QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#655093#9443. Left Equals Rightucup-team1074WA 117ms11916kbC++231.9kb2024-10-19 00:28:242024-10-19 00:28:28

Judging History

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

  • [2024-10-19 00:28:28]
  • 评测
  • 测评结果:WA
  • 用时:117ms
  • 内存:11916kb
  • [2024-10-19 00:28:24]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define pb push_back
#define int long long
#define x first
#define y second 
#define endl '\n'
const LL maxn = 4e05+7;
const LL N = 5e05+10;
const LL mod = 998244353;
const int inf = 0x3f3f3f3f;
const LL llinf = 5e18;
typedef pair<int,int>pl;
priority_queue<LL , vector<LL>, greater<LL> >mi;//小根堆
priority_queue<LL> ma;//大根堆
#define LL long long
struct comb{
	vector<LL>f , g;//阶乘以及分母式子的逆元
	comb(){}
	comb(int n) : f(n) , g(n){
		init(n);
	}
	LL qpow(LL a , LL b)//快速幂
	{
		LL sum=1;
		while(b){
			if(b&1){
				sum=sum*a%mod;
			}
			a=a*a%mod;
			b>>=1;
		}
		return sum;
	}
	void init(int n){
		f[0] = g[0] = 1;
		for(int i = 1;i < n; i ++){
	    	f[i] = f[i - 1] * i % mod; //计算i的阶乘
		}
		g[n - 1] = qpow(f[n - 1] , mod - 2);
		for(int i = n - 1 ; i >= 1 ; i --){
			g[i - 1] = g[i] * i % mod;
		}
	}
	LL get(int n,int m){ //得到C(n,m)的组合数答案
		if(n < m)
			return 0;
		else
	    	return f[n] * g[m] % mod * g[n-m] % mod;
	}	
}calc(1000);
void solve() 
{
	vector<vector<int>>dp(10005 , vector<int>(105 , 0));
	dp[0][0] = 1;
	int tot = 0;
	int n;
	cin >> n;
	for(int i = 0 ; i < n ; i ++){
		int x;
		cin >> x;
		tot += x;
		for(int k = 100 ; k >= 1 ; k --){
			for(int j = 10000 - x; j >= 0 ; j --){
				dp[j + x][k] += dp[j][k - 1];
			}			
		}
	}
	int ans = 0;
	if(tot & 1){
		cout << 0 << endl;
		return;
	}
	for(int i = 1 ; i <= n ; i ++){
		ans += (dp[tot / 2][i] * calc.f[i] % mod) * calc.f[n - i];
		ans %= mod;
	}
	//DP[I] = (1-P)DP[I] + DP[I - 1] * t * P
	cout << ans << endl;
}            
signed main() 
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(10);
    int t=1;
	//cin>>t;
    while(t--)
    {
    	solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 8ms
memory: 11440kb

input:

3
4 9 5

output:

4

result:

ok "4"

Test #2:

score: 0
Accepted
time: 9ms
memory: 11768kb

input:

2
100 100

output:

2

result:

ok "2"

Test #3:

score: 0
Accepted
time: 21ms
memory: 11896kb

input:

8
3 2 6 3 1 2 4 5

output:

11520

result:

ok "11520"

Test #4:

score: 0
Accepted
time: 4ms
memory: 11916kb

input:

2
93 93

output:

2

result:

ok "2"

Test #5:

score: 0
Accepted
time: 4ms
memory: 11736kb

input:

2
62 45

output:

0

result:

ok "0"

Test #6:

score: 0
Accepted
time: 7ms
memory: 11752kb

input:

3
32 68 36

output:

4

result:

ok "4"

Test #7:

score: 0
Accepted
time: 10ms
memory: 11752kb

input:

3
27 2 25

output:

4

result:

ok "4"

Test #8:

score: 0
Accepted
time: 21ms
memory: 11780kb

input:

10
38 27 36 88 77 25 73 44 11 21

output:

126720

result:

ok "126720"

Test #9:

score: 0
Accepted
time: 22ms
memory: 11748kb

input:

10
93 78 29 81 14 20 18 71 85 48

output:

0

result:

ok "0"

Test #10:

score: 0
Accepted
time: 23ms
memory: 11860kb

input:

9
57 19 88 13 55 43 27 10 74

output:

5760

result:

ok "5760"

Test #11:

score: 0
Accepted
time: 26ms
memory: 11828kb

input:

10
80 1 44 85 32 85 3 4 80 45

output:

0

result:

ok "0"

Test #12:

score: 0
Accepted
time: 23ms
memory: 11752kb

input:

10
56 72 93 39 70 78 3 10 84 48

output:

0

result:

ok "0"

Test #13:

score: 0
Accepted
time: 21ms
memory: 11740kb

input:

10
2 58 36 81 100 85 11 39 24 50

output:

118080

result:

ok "118080"

Test #14:

score: 0
Accepted
time: 27ms
memory: 11736kb

input:

10
70 23 3 26 98 18 63 32 22 25

output:

158400

result:

ok "158400"

Test #15:

score: 0
Accepted
time: 21ms
memory: 11440kb

input:

10
42 92 12 71 85 68 78 89 98 30

output:

0

result:

ok "0"

Test #16:

score: 0
Accepted
time: 27ms
memory: 11860kb

input:

10
26 5 25 35 77 46 81 13 73 32

output:

0

result:

ok "0"

Test #17:

score: 0
Accepted
time: 27ms
memory: 11752kb

input:

10
37 43 7 51 89 86 84 26 28 15

output:

103680

result:

ok "103680"

Test #18:

score: -100
Wrong Answer
time: 117ms
memory: 11848kb

input:

58
84 96 24 20 3 10 27 57 98 49 32 52 67 18 100 6 100 4 4 88 24 77 75 95 18 83 58 75 71 99 18 53 68 65 76 37 51 19 65 63 28 59 84 59 80 73 83 41 96 30 96 5 13 56 92 84 30 72

output:

429764033

result:

wrong answer 1st words differ - expected: '670239800', found: '429764033'