QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#637153 | #9443. Left Equals Right | ucup-team4992# | WA | 1ms | 5764kb | C++20 | 860b | 2024-10-13 10:17:35 | 2024-10-13 10:17:35 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 100+5;
const ll mod = 998244353;
int n, s;
int a[MAXN];
ll ans = 0, fac[MAXN];
ll dp[MAXN][MAXN*MAXN];
int main(){
cin >> n;
fac[0] = 1;
for(int i = 1; i <= n; i++){
fac[i] = fac[i-1]*i%mod;
}
for(int i = 1; i <= n; i++){
cin >> a[i];
s += a[i];
}
if(s & 1){
cout << "0\n";
return 0;
}
s /= 2;
dp[0][0] = 1;
for(int i = 1; i <= n; i++){
for(int j = i; j >= 1; j--){
for(int k = 0; k <= 100*j; k++){
dp[j][k] = (dp[j][k] + dp[j-1][k-a[i]]) % mod;
}
}
}
for(int i = 1; i < n; i++){
ans = (ans + dp[i][s]*fac[i]%mod*fac[n-i]%mod);
}
cout << ans%mod << "\n";
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 5764kb
input:
3 4 9 5
output:
973939548
result:
wrong answer 1st words differ - expected: '4', found: '973939548'